diff options
| author | Simon Tatham <anakin@pobox.com> | 1999-10-28 09:53:22 +0000 |
|---|---|---|
| committer | Simon Tatham <anakin@pobox.com> | 1999-10-28 09:53:22 +0000 |
| commit | 06bbfc1a23c38d623c88adffb681e89a367ab5c5 (patch) | |
| tree | 257800df1a4330cd7a7249b0d702f3b0be12a2ff /misc | |
| parent | 146487494dcfaf6a7c4cb84b094ee287598638c2 (diff) | |
| download | halibut-06bbfc1a23c38d623c88adffb681e89a367ab5c5.zip halibut-06bbfc1a23c38d623c88adffb681e89a367ab5c5.tar.gz halibut-06bbfc1a23c38d623c88adffb681e89a367ab5c5.tar.bz2 halibut-06bbfc1a23c38d623c88adffb681e89a367ab5c5.tar.xz | |
Distinguish bogus frees from double frees
[originally from svn r262]
Diffstat (limited to 'misc')
| -rwxr-xr-x | misc/logalloc | 12 |
1 files changed, 10 insertions, 2 deletions
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"; } } |