Skip to content

Commit

Permalink
Merge pull request #33774 from nextcloud/hash-wrapper-closed-hash
Browse files Browse the repository at this point in the history
handle cases where the hash context gets cleaned up before the hash wrapper
  • Loading branch information
PVince81 authored Sep 1, 2022
2 parents affa402 + a9575a7 commit 7ea8427
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion lib/private/Files/Stream/HashWrapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,11 @@ public function stream_read($count) {

public function stream_close() {
if (is_callable($this->callback)) {
call_user_func($this->callback, hash_final($this->hash));
// if the stream is closed as a result of the end-of-request GC, the hash context might be cleaned up before this stream
if ($this->hash instanceof \HashContext) {
$hash = hash_final($this->hash);
call_user_func($this->callback, $hash);
}
// prevent further calls by potential PHP 7 GC ghosts
$this->callback = null;
}
Expand Down

0 comments on commit 7ea8427

Please sign in to comment.