Skip to content

Commit c265924

Browse files
[HttpKernel] Guard against bad profile data
1 parent 9fb7242 commit c265924

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

Profiler/FileProfilerStorage.php

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,11 @@ public function read($token): ?Profile
123123
$file = 'compress.zlib://'.$file;
124124
}
125125

126-
return $this->createProfileFromData($token, unserialize(file_get_contents($file)));
126+
if (!$data = unserialize(file_get_contents($file))) {
127+
return null;
128+
}
129+
130+
return $this->createProfileFromData($token, $data);
127131
}
128132

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

300-
$profile->addChild($this->createProfileFromData($token, unserialize(file_get_contents($file)), $profile));
304+
if (!$childData = unserialize(file_get_contents($file))) {
305+
continue;
306+
}
307+
308+
$profile->addChild($this->createProfileFromData($token, $childData, $profile));
301309
}
302310

303311
return $profile;

0 commit comments

Comments
 (0)