debug-engine: Handle wasm_debug_instance_get_current_object_name failure (#1453)

Use an empty string instead of stack garbage.
This commit is contained in:
YAMAMOTO Takashi 2022-09-05 20:45:20 +09:00 committed by GitHub
parent 8fcc556e50
commit 0ca271873d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -108,8 +108,11 @@ process_xfer(WASMGDBServer *server, const char *name, char *args)
os_mutex_lock(&tmpbuf_lock);
#if WASM_ENABLE_LIBC_WASI != 0
char objname[128];
wasm_debug_instance_get_current_object_name(
(WASMDebugInstance *)server->thread->debug_instance, objname, 128);
if (!wasm_debug_instance_get_current_object_name(
(WASMDebugInstance *)server->thread->debug_instance, objname,
128)) {
objname[0] = 0; /* use an empty string */
}
snprintf(tmpbuf, MAX_PACKET_SIZE,
"l<library-list><library name=\"%s\"><section "
"address=\"0x%" PRIx64 "\"/></library></library-list>",