aboutsummaryrefslogtreecommitdiff
path: root/gdb/remote-notif.c
diff options
context:
space:
mode:
authorYao Qi <yao@codesourcery.com>2013-08-15 09:09:08 +0800
committerYao Qi <yao@codesourcery.com>2013-12-02 14:44:14 +0800
commit62972e0b66f4247f56c795ee55bc0825933a7bed (patch)
treeeda7005f3e1f7abcee6f0410243df61edecbd018 /gdb/remote-notif.c
parentf9b0da3d5833ad5f809422f3084b0ef8fa5c5762 (diff)
downloadfsf-binutils-gdb-62972e0b66f4247f56c795ee55bc0825933a7bed.zip
fsf-binutils-gdb-62972e0b66f4247f56c795ee55bc0825933a7bed.tar.gz
fsf-binutils-gdb-62972e0b66f4247f56c795ee55bc0825933a7bed.tar.bz2
Fix PR remote/15974
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.
Diffstat (limited to 'gdb/remote-notif.c')
-rw-r--r--gdb/remote-notif.c15
1 files changed, 9 insertions, 6 deletions
diff --git a/gdb/remote-notif.c b/gdb/remote-notif.c
index 0d59279..163979d 100644
--- a/gdb/remote-notif.c
+++ b/gdb/remote-notif.c
@@ -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