Skip to content

Commit

Permalink
[HttpKernel] Guard against bad profile data
Browse files Browse the repository at this point in the history
  • Loading branch information
nicolas-grekas committed Mar 2, 2022
1 parent 9fb7242 commit c265924
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions Profiler/FileProfilerStorage.php
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,11 @@ public function read($token): ?Profile
$file = 'compress.zlib://'.$file;
}

return $this->createProfileFromData($token, unserialize(file_get_contents($file)));
if (!$data = unserialize(file_get_contents($file))) {
return null;
}

return $this->createProfileFromData($token, $data);
}

/**
Expand Down Expand Up @@ -297,7 +301,11 @@ protected function createProfileFromData($token, $data, $parent = null)
$file = 'compress.zlib://'.$file;
}

$profile->addChild($this->createProfileFromData($token, unserialize(file_get_contents($file)), $profile));
if (!$childData = unserialize(file_get_contents($file))) {
continue;
}

$profile->addChild($this->createProfileFromData($token, $childData, $profile));
}

return $profile;
Expand Down

0 comments on commit c265924

Please sign in to comment.