]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
Fix NULL dereference if no integer arg given to monitor block_list cmd
authorPhilippe Waroquiers <philippe.waroquiers@skynet.be>
Mon, 21 Jan 2013 22:05:47 +0000 (22:05 +0000)
committerPhilippe Waroquiers <philippe.waroquiers@skynet.be>
Mon, 21 Jan 2013 22:05:47 +0000 (22:05 +0000)
Reported by Florian (spotted by coverity).

git-svn-id: svn://svn.valgrind.org/valgrind/trunk@13257

memcheck/mc_main.c

index 1197c9c2a7a5154459ea5075e408625fdccc6ff4..3ee4abd9151ba8cc68e2647da45af8aff900e45e 100644 (file)
@@ -5386,9 +5386,10 @@ static Bool handle_gdb_monitor_command (ThreadId tid, HChar *req)
       HChar *endptr;
       UInt lr_nr = 0;
       wl = VG_(strtok_r) (NULL, " ", &ssaveptr);
-      lr_nr = VG_(strtoull10) (wl, &endptr);
-      if (wl != NULL && *endptr != '\0') {
-         VG_(gdb_printf) ("malformed integer\n");
+      if (wl != NULL)
+         lr_nr = VG_(strtoull10) (wl, &endptr);
+      if (wl == NULL || *endptr != '\0') {
+         VG_(gdb_printf) ("malformed or missing integer\n");
       } else {
          // lr_nr-1 as what is shown to the user is 1 more than the index in lr_array.
          if (lr_nr == 0 || ! MC_(print_block_list) (lr_nr-1))