From mboxrd@z Thu Jan 1 00:00:00 1970 From: Michael Elizabeth Chastain To: gdb-patches@sources.redhat.com Subject: [RFA] gdb/win32-nat.c: check for NULL before calling strtoul Date: Sat, 17 Mar 2001 23:52:00 -0000 Message-id: <200103180752.XAA02531@bosch.cygnus.com> X-SW-Source: 2001-03/msg00331.html 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 * 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)