From 06bbfc1a23c38d623c88adffb681e89a367ab5c5 Mon Sep 17 00:00:00 2001 From: Simon Tatham Date: Thu, 28 Oct 1999 09:53:22 +0000 Subject: Distinguish bogus frees from double frees [originally from svn r262] --- misc/logalloc | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'misc/logalloc') diff --git a/misc/logalloc b/misc/logalloc index 83e9dad..cdc4504 100755 --- a/misc/logalloc +++ b/misc/logalloc @@ -27,15 +27,23 @@ while (<>) { if /^(\S+) (\S+) free\((\S+)\)$/; $null = $1, next if /^null pointer is (\S+)$/; if ($in ne "") { - $bad = &null($in) ? "null" : "bad"; - $errors=1, print "($.) $file:$line: attempt to $call() $bad pointer\n" + if (&null($in)) { + $bad = "null pointer"; + } elsif (defined $lastalloc{$in}) { + $bad = "already-freed pointer (last alloc $lastalloc{$in}, last free $lastfree{$in})"; + } else { + $bad = "bad pointer"; + } + $errors=1, print "($.) $file:$line: $call() $bad\n" if $record{$in} eq ""; + $lastfree{$in}="($.) $file:$line"; $record{$in}=""; } if ($out ne "" && !&null($out)) { $errors=1, print "($.) $file:$line: $call() returned already ". "allocated pointer\n" if $record{$out} ne ""; $record{$out}="($.) $file:$line: $call()"; + $lastalloc{$out}="($.) $file:$line"; } } -- cgit v1.1