Fix crash handler buffer truncation warnings
Fixed compiler warnings in DEBUG crash handler code about potential buffer truncation when constructing command strings. Changes: - Increased cmd buffer from 512 to 1536 bytes (line 91) - Increased gdb_cmd buffer from 512 to 1536 bytes (line 118) This provides sufficient space for the full exe_path (max 1024 bytes) plus command text, eliminating truncation warnings while maintaining safety with -Wformat-truncation checks. Debug build now compiles cleanly with zero warnings.
+2 −2 · 1 file changed
-
src/main.c+2 −2
@@ -88,7 +88,7 @@ void crash_handler(int sig) { fprintf(stderr, " Runtime address: %p\n", array[i]); fprintf(stderr, " File offset: %p\n", file_offset); - char cmd[512]; + char cmd[1536]; snprintf(cmd, sizeof(cmd), "addr2line -e '%s' -f -C -p %p 2>&1", exe_path, file_offset); @@ -115,7 +115,7 @@ void crash_handler(int sig) { } fprintf(stderr, "\n=== Using gdb to get line info ===\n"); - char gdb_cmd[512]; + char gdb_cmd[1536]; snprintf(gdb_cmd, sizeof(gdb_cmd), "gdb -q '%s' -ex 'info line *%p' -ex 'quit' 2>/dev/null | grep -E \"Line|at\"", exe_path, array[3]);