Skip to content

wasm_runtime_common.c cp might not be freed #4675

@linear0211

Description

@linear0211

for (i = 0; i < addr_pool_size; i++) {
char *cp, *address, *mask;
bool ret = false;
cp = bh_strdup(addr_pool[i]);
if (!cp) {
set_error_buf(error_buf, error_buf_size,
"Init wasi environment failed: copy address failed");
goto fail;
}
address = strtok(cp, "/");
mask = strtok(NULL, "/");
if (!mask) {
snprintf(error_buf, error_buf_size,
"Invalid address pool entry: %s, must be in the format of "
"ADDRESS/MASK",
addr_pool[i]);
goto fail;
}
ret = addr_pool_insert(apool, address, (uint8)atoi(mask));
wasm_runtime_free(cp);
if (!ret) {
set_error_buf(error_buf, error_buf_size,
"Init wasi environment failed: store address failed");
goto fail;
}
}

It seems that cp is not freed in some failure paths.
Please check whether this observation is correct.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions