This is the mail archive of the
gdb-patches@sources.redhat.com
mailing list for the GDB project.
[RFA] gdb/win32-nat.c: check for NULL before calling strtoul
- To: gdb-patches at sources dot redhat dot com
- Subject: [RFA] gdb/win32-nat.c: check for NULL before calling strtoul
- From: Michael Elizabeth Chastain <chastain at cygnus dot com>
- Date: Sat, 17 Mar 2001 23:52:23 -0800
This patch fixes PR gdb/43, a coding error in child_attach. Cygwin's
implementation of strtoul dumps core if the input pointer is NULL.
This means gdb dumps core on a plain "attach" command with no arguments.
This fix enables the test script gdb.base/default.exp to run to
completion.
I tested this on Windows 2000 Professional + cygwin 1.1.8. I gave a
plain "attach" command by hand and also ran gdb.base/default.exp.
OK to apply?
Michael
===
2001-03-17 Michael Chastain <chastain@redhat.com>
* win32-nat.c (child_attach): check args for NULL before passing
to strtoul. This fixes PR gdb/43.
Index: gdb/win32-nat.c
===================================================================
RCS file: /cvs/src/src/gdb/win32-nat.c,v
retrieving revision 1.25
diff -c -3 -p -r1.25 win32-nat.c
*** gdb/win32-nat.c 2001/03/06 08:21:18 1.25
--- gdb/win32-nat.c 2001/03/18 07:40:02
*************** static void
*** 1015,1025 ****
child_attach (char *args, int from_tty)
{
BOOL ok;
! DWORD pid = strtoul (args, 0, 0);
if (!args)
error_no_arg ("process-id to attach");
ok = DebugActiveProcess (pid);
if (!ok)
--- 1015,1026 ----
child_attach (char *args, int from_tty)
{
BOOL ok;
! DWORD pid;
if (!args)
error_no_arg ("process-id to attach");
+ pid = strtoul (args, 0, 0);
ok = DebugActiveProcess (pid);
if (!ok)