mirror of
https://github.com/curl/curl.git
synced 2026-06-16 10:25:39 +03:00
memanalyze: tell if the same desriptor is returned again
If a previous socket() got a certain file descriptor and there was no close in between, this indicates something is seriously wrong.
This commit is contained in:
parent
c7ca9ba1ac
commit
bc1d4414b2
1 changed files with 10 additions and 1 deletions
|
|
@ -304,6 +304,10 @@ while(<$fileh>) {
|
|||
$function = $3;
|
||||
|
||||
if($function =~ /socket\(\) = (\d*)/) {
|
||||
my $fd = $1;
|
||||
if($filedes{$fd}) {
|
||||
print "Suspicious: socket() returns same descriptor *again* ($fd). Last created at ".$getfile{$fd}."\n";
|
||||
}
|
||||
$filedes{$1}=1;
|
||||
$getfile{$1}="$source:$linenum";
|
||||
$openfile++;
|
||||
|
|
@ -323,10 +327,15 @@ while(<$fileh>) {
|
|||
$openfile++;
|
||||
}
|
||||
elsif($function =~ /sclose\((\d*)\)/) {
|
||||
if($filedes{$1} != 1) {
|
||||
my $fd = $1;
|
||||
if($filedes{$fd} != 1) {
|
||||
print "Close without open: $line\n";
|
||||
}
|
||||
else {
|
||||
if($trace) {
|
||||
printf("CLOSE($fd) at $source:$linenum, created at ".
|
||||
$getfile{$1}."\n");
|
||||
}
|
||||
$filedes{$1}=0; # closed now
|
||||
$openfile--;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue