mirror of
https://github.com/danog/byte-stream.git
synced 2024-11-26 20:04:51 +01:00
Fix null pointer access in GzipInputStream
This commit is contained in:
parent
56ec64c508
commit
59b2454253
@ -53,4 +53,4 @@ Loop::run(function () use ($stderr, $in, $out) {
|
||||
|
||||
$stderr->write('read ' . $bytes . ' byte(s) in ' . round($t, 3) . ' second(s) => ' . round($bytes / 1024 / 1024 / $t, 1) . ' MiB/s' . PHP_EOL);
|
||||
$stderr->write('peak memory usage of ' . round(memory_get_peak_usage(true) / 1024 / 1024, 1) . ' MiB' . PHP_EOL);
|
||||
});
|
||||
});
|
||||
|
@ -26,6 +26,11 @@ class GzipInputStream implements InputStream {
|
||||
|
||||
$data = yield $this->source->read();
|
||||
|
||||
// Needs a double guard, as stream might have been closed while reading
|
||||
if ($this->resource === null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if ($data === null) {
|
||||
$decompressed = \inflate_add($this->resource, "", \ZLIB_FINISH);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user