From 7822233964cb46b69704e6637c9c6c2eb2381c94 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Fri, 19 Jan 2001 12:20:30 +0000 Subject: [PATCH] Made the complaint on free-twice errors a lot better --- memanalyze.pl | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/memanalyze.pl b/memanalyze.pl index aa6db4c81..86c967c8c 100755 --- a/memanalyze.pl +++ b/memanalyze.pl @@ -26,13 +26,17 @@ while() { if($function =~ /free\(0x([0-9a-f]*)/) { $addr = $1; - if($sizeataddr{$addr} <= 0) { + if($sizeataddr{$addr} == 0) { print "FREE ERROR: No memory allocated: $line\n"; } + elsif(-1 == $sizeataddr{$addr}) { + print "FREE ERROR: Memory freed twice: $line\n"; + print "FREE ERROR: Previously freed at: ".$getmem{$addr}."\n"; + } else { $totalmem -= $sizeataddr{$addr}; - $sizeataddr{$addr}=0; - $getmem{$addr}=""; # forget after a good free() + $sizeataddr{$addr}=-1; # set -1 to mark as freed + $getmem{$addr}="$source:$linenum"; } } elsif($function =~ /malloc\((\d*)\) = 0x([0-9a-f]*)/) {