Skip to content

Commit

Permalink
gdb_packet: Log vasprintf failures in gdb_voutf()
Browse files Browse the repository at this point in the history
  • Loading branch information
ALTracer committed May 27, 2024
1 parent 7ba6897 commit 8b4d376
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/gdb_packet.c
Original file line number Diff line number Diff line change
Expand Up @@ -349,9 +349,12 @@ void gdb_out(const char *const buf)

void gdb_voutf(const char *const fmt, va_list ap)
{
char *buf;
if (vasprintf(&buf, fmt, ap) < 0)
char *buf = NULL;
if (vasprintf(&buf, fmt, ap) < 0) {
/* Heap exhaustion. Report with puts() elsewhere. */
DEBUG_ERROR("gdb_voutf: vasprintf failed\n");
return;
}

gdb_out(buf);
free(buf);
Expand Down

0 comments on commit 8b4d376

Please sign in to comment.