From: Philippe Waroquiers Date: Mon, 21 Jan 2013 22:05:47 +0000 (+0000) Subject: Fix NULL dereference if no integer arg given to monitor block_list cmd X-Git-Tag: svn/VALGRIND_3_9_0~424 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=35ee46968d72e89b61189e146d97ae09d102ff67;p=thirdparty%2Fvalgrind.git Fix NULL dereference if no integer arg given to monitor block_list cmd Reported by Florian (spotted by coverity). git-svn-id: svn://svn.valgrind.org/valgrind/trunk@13257 --- diff --git a/memcheck/mc_main.c b/memcheck/mc_main.c index 1197c9c2a7..3ee4abd915 100644 --- a/memcheck/mc_main.c +++ b/memcheck/mc_main.c @@ -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))