From 0ca271873df7fcdb13694209f7210cc9d7bceef0 Mon Sep 17 00:00:00 2001 From: YAMAMOTO Takashi Date: Mon, 5 Sep 2022 20:45:20 +0900 Subject: [PATCH] debug-engine: Handle wasm_debug_instance_get_current_object_name failure (#1453) Use an empty string instead of stack garbage. --- core/iwasm/libraries/debug-engine/handler.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/core/iwasm/libraries/debug-engine/handler.c b/core/iwasm/libraries/debug-engine/handler.c index f45638343..da07f80da 100644 --- a/core/iwasm/libraries/debug-engine/handler.c +++ b/core/iwasm/libraries/debug-engine/handler.c @@ -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
",