Add null pointer check in ctf_xfer_partial
authorYao Qi <yao@codesourcery.com>
Fri, 18 Apr 2014 11:22:23 +0000 (19:22 +0800)
committerYao Qi <yao@codesourcery.com>
Sat, 19 Apr 2014 02:36:08 +0000 (10:36 +0800)
I find a gdb crash when gdb reads ctf trace.  The crash is caused by passing
NULL to strcmp.  This patch is to add null pointer check, as what we did
somewhere else in ctf.c.

gdb:

2014-04-19  Yao Qi  <yao@codesourcery.com>

* ctf.c (ctf_xfer_partial): Check 'name' is NULL before strcmp.

gdb/ChangeLog
gdb/ctf.c

index 21907fabd0a00d7214b03e0a33c67d7a6ef3733a..2d2b839888e972cce44fc98cd8e92efbb6dfb7fe 100644 (file)
@@ -1,3 +1,7 @@
+2014-04-19  Yao Qi  <yao@codesourcery.com>
+
+       * ctf.c (ctf_xfer_partial): Check 'name' is NULL before strcmp.
+
 2014-04-18  Siva Chandra Reddy  <sivachandra@google.com>
 
        * valops.c (oload_method_static): Remove unnecessary argument
index ebd40d6d83972a8dccb017c26c5598fccfb706e3..b684a3603f307d9ea9df8c2b42c621f0521ac5ab 100644 (file)
--- a/gdb/ctf.c
+++ b/gdb/ctf.c
@@ -1399,7 +1399,7 @@ ctf_xfer_partial (struct target_ops *ops, enum target_object object,
            = bt_ctf_iter_read_event (ctf_iter);
          const char *name = bt_ctf_event_name (event);
 
-         if (strcmp (name, "frame") == 0)
+         if (name == NULL || strcmp (name, "frame") == 0)
            break;
          else if (strcmp (name, "memory") != 0)
            {