From: Luis Machado Date: Mon, 24 Oct 2016 22:51:33 +0000 (-0500) Subject: Fix potential NULL pointer dereference X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=b5e1db87897cabfd9beb8b1bd49f7d965c0f2607;p=binutils-gdb.git Fix potential NULL pointer dereference This patch addresses a potential NULL pointer dereference when we try to duplicate a string. The input pointer can be NULL and that may lead to crashes. We simply add a check for that case. gdb/ChangeLog: 2016-10-24 Luis Machado * exec.c (exec_file_locate_attach): Prevent NULL pointer dereference when duplicating a string. --- diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 388cc1ff61f..43175ffcde8 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,8 @@ +2016-10-24 Luis Machado + + * exec.c (exec_file_locate_attach): Prevent NULL pointer dereference + when duplicating a string. + 2016-10-24 Luis Machado * exec.c (exception_print_same): Fix string comparison to use diff --git a/gdb/exec.c b/gdb/exec.c index 67ecc636307..6e2a296d2e6 100644 --- a/gdb/exec.c +++ b/gdb/exec.c @@ -227,7 +227,8 @@ exec_file_locate_attach (int pid, int defer_bp_reset, int from_tty) prev_err = err; /* Save message so it doesn't get trashed by the catch below. */ - prev_err.message = xstrdup (err.message); + if (err.message != NULL) + prev_err.message = xstrdup (err.message); } END_CATCH