Skip to content

Commit

Permalink
refactor: wasm_memory_get_string
Browse files Browse the repository at this point in the history
  • Loading branch information
bushidocodes committed Dec 10, 2021
1 parent 57d9538 commit 452db10
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions runtime/include/wasm_memory.h
Original file line number Diff line number Diff line change
Expand Up @@ -283,10 +283,11 @@ wasm_memory_get_string(struct wasm_memory *self, uint32_t offset, uint32_t size)
{
assert(offset + (sizeof(char) * size) <= self->size);

for (uint32_t i = 0; i < size; i++) {
if (self->buffer[offset + i] == '\0') return (char *)&self->buffer[offset];
if (strnlen((const char *)&self->buffer[offset], size) < size) {
return (char *)&self->buffer[offset];
} else {
return NULL;
}
return NULL;
}

/**
Expand Down

0 comments on commit 452db10

Please sign in to comment.