[wasm-api] Make buffer_copy_contents return zero length on mem fail

This commit is contained in:
Behdad Esfahbod 2023-02-24 20:01:22 -07:00
parent 16ecb96922
commit 77f0f3c11a
3 changed files with 6 additions and 15 deletions

View File

@ -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

View File

@ -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;

View File

@ -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;