Skip to content

Commit

Permalink
Fix null pointer access in GzipInputStream
Browse files Browse the repository at this point in the history
  • Loading branch information
kelunik committed May 8, 2017
1 parent 56ec64c commit 59b2454
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
2 changes: 1 addition & 1 deletion examples/benchmark-throughput.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,4 +53,4 @@

$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);
});
});
5 changes: 5 additions & 0 deletions lib/GzipInputStream.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,11 @@ public function read(): Promise {

$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);

Expand Down

0 comments on commit 59b2454

Please sign in to comment.