aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Stenberg <daniel@haxx.se>2001-01-19 12:20:30 +0000
committerDaniel Stenberg <daniel@haxx.se>2001-01-19 12:20:30 +0000
commit7822233964cb46b69704e6637c9c6c2eb2381c94 (patch)
tree60893fbfd1c5e6ccdfc9e16b58fde9a0112ed73f
parent022315089b47bd58480578aa4793b76bf5b06a17 (diff)
Made the complaint on free-twice errors a lot better
-rwxr-xr-xmemanalyze.pl10
1 files 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(<STDIN>) {
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]*)/) {