This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
[RFA] gdbserver/hostio.c, handle_close: check for null
- From: Michael Snyder <msnyder at vmware dot com>
- To: "gdb-patches at sourceware dot org" <gdb-patches at sourceware dot org>
- Date: Fri, 04 Mar 2011 12:16:11 -0800
- Subject: [RFA] gdbserver/hostio.c, handle_close: check for null
This one's a little iffey...
The conditional in the while loop implies that the pointer may wind up
as null. Therefore it would make sense to check it for null before
dereferencing it.
Alternatively, if it can't wind up as null, we should take the test out
of the while loop.
Michael
2011-03-04 Michael Snyder <msnyder@vmware.com>
* gdbserver/hostio.c (handle_close): Check for null before deref.
Index: gdbserver/hostio.c
===================================================================
RCS file: /cvs/src/src/gdb/gdbserver/hostio.c,v
retrieving revision 1.14
diff -u -p -u -p -r1.14 hostio.c
--- gdbserver/hostio.c 28 Feb 2011 15:55:08 -0000 1.14
+++ gdbserver/hostio.c 4 Mar 2011 20:12:48 -0000
@@ -422,7 +422,8 @@ handle_close (char *own_buf)
open_fd_p = &(*open_fd_p)->next;
old_fd = *open_fd_p;
- *open_fd_p = (*open_fd_p)->next;
+ if (*open_fd_p != NULL)
+ *open_fd_p = (*open_fd_p)->next;
free (old_fd);
hostio_reply (own_buf, ret);