Fix PR remote/15974
authorYao Qi <yao@codesourcery.com>
Thu, 15 Aug 2013 01:09:08 +0000 (09:09 +0800)
committerYao Qi <yao@codesourcery.com>
Mon, 2 Dec 2013 06:44:14 +0000 (14:44 +0800)
In remote-notif.c:handle_notification, we have a loop,

  for (i = 0; i < ARRAY_SIZE (notifs); i++)
    {
      nc = notifs[i];
      if (strncmp (buf, nc->name, strlen (nc->name)) == 0
  && buf[strlen (nc->name)] == ':')
break;
    }

  /* We ignore notifications we don't recognize, for compatibility
     with newer stubs.  */
  if (nc == NULL)
    return;

If the notification is not in the list 'notifs', the last entry is
used, which is wrong.  It should be NULL.  This patch fixes it.

gdb:

2013-12-02  Pedro Alves  <palves@redhat.com>

PR remote/15974
* remote-notif.c (handle_notification): Return early if no
notification is found.

gdb/ChangeLog
gdb/remote-notif.c

index 62abbaca43f2787dca25f387db0ff883df301522..e7998b9aa6f93602e21d6fe8f5c8a9c55793e97d 100644 (file)
@@ -1,3 +1,9 @@
+2013-12-02  Pedro Alves  <palves@redhat.com>
+
+       PR remote/15974
+       * remote-notif.c (handle_notification): Return early if no
+       notification is found.
+
 2013-12-02  Joel Brobecker  <brobecker@adacore.com>
 
        * common/filestuff.c (fdwalk): Add "defined(RLIMIT_NOFILE)"
index 0d5927912b1b190a913c79a34fd60ac9434013a3..163979d211108687f0c779c6889c2ac9b57e8009 100644 (file)
@@ -127,22 +127,25 @@ remote_async_get_pending_events_handler (gdb_client_data data)
 void
 handle_notification (struct remote_notif_state *state, char *buf)
 {
-  struct notif_client *nc = NULL;
-  int i;
+  struct notif_client *nc;
+  size_t i;
 
   for (i = 0; i < ARRAY_SIZE (notifs); i++)
     {
-      nc = notifs[i];
-      if (strncmp (buf, nc->name, strlen (nc->name)) == 0
-         && buf[strlen (nc->name)] == ':')
+      const char *name = notifs[i]->name;
+
+      if (strncmp (buf, name, strlen (name)) == 0
+         && buf[strlen (name)] == ':')
        break;
     }
 
   /* We ignore notifications we don't recognize, for compatibility
      with newer stubs.  */
-  if (nc == NULL)
+  if (i == ARRAY_SIZE (notifs))
     return;
 
+  nc =  notifs[i];
+
   if (state->pending_event[nc->id] != NULL)
     {
       /* We've already parsed the in-flight reply, but the stub for some
This page took 0.030637 seconds and 4 git commands to generate.