[wasm-api] Make buffer_copy_contents return zero length on mem fail
This commit is contained in:
parent
16ecb96922
commit
77f0f3c11a
|
@ -109,8 +109,8 @@ HB_WASM_API_COMPOUND (buffer_contents_t, buffer_copy_contents) (HB_WASM_EXEC_ENV
|
|||
ret.info = wasm_runtime_module_dup_data (module_inst, (const char *) buffer->info, length * sizeof (buffer->info[0]));
|
||||
ret.pos = wasm_runtime_module_dup_data (module_inst, (const char *) buffer->pos, length * sizeof (buffer->pos[0]));
|
||||
|
||||
if (unlikely (buffer->successful && (!ret.info || !ret.pos)))
|
||||
buffer->successful = false;
|
||||
if (!ret.info || !ret.pos)
|
||||
ret.length = 0;
|
||||
}
|
||||
|
||||
HB_WASM_API (bool_t, buffer_set_contents) (HB_WASM_EXEC_ENV
|
||||
|
|
|
@ -348,21 +348,10 @@ retry:
|
|||
|
||||
wasm_runtime_module_free (module_inst, arguments[2].of.i32);
|
||||
|
||||
if (unlikely (buffer->in_error ()))
|
||||
{
|
||||
DEBUG_MSG (WASM, module_inst, "Buffer in error. Memory allocation fail in the wasm?");
|
||||
if (retried)
|
||||
goto fail;
|
||||
buffer->successful = true;
|
||||
retried = true;
|
||||
release_shape_plan (face_data, plan);
|
||||
goto retry;
|
||||
}
|
||||
|
||||
if (unlikely (!ret))
|
||||
if (unlikely (!ret || !results[0].of.i32))
|
||||
{
|
||||
DEBUG_MSG (WASM, module_inst, "Calling shape() failed: %s",
|
||||
wasm_runtime_get_exception(module_inst));
|
||||
wasm_runtime_get_exception (module_inst));
|
||||
if (retried)
|
||||
goto fail;
|
||||
buffer->successful = true;
|
||||
|
|
|
@ -75,6 +75,8 @@ shape (void *shape_plan,
|
|||
}
|
||||
|
||||
buffer_contents_t contents = buffer_copy_contents (buffer);
|
||||
if (!contents.length)
|
||||
return false;
|
||||
|
||||
gr_segment *seg = nullptr;
|
||||
const gr_slot *is;
|
||||
|
|
Loading…
Reference in New Issue