aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRobin Appelman <robin@icewind.nl>2022-08-31 15:05:10 +0200
committerRobin Appelman <robin@icewind.nl>2022-08-31 15:05:10 +0200
commita9575a7029f21226ef2f8372be4f7e433e6a59fa (patch)
treed7fed53d4902463d3b0b460e21aef5bd34508157
parentf56ecf92426026c913497bea9f7ca99e8d3ac631 (diff)
downloadnextcloud-server-a9575a7029f21226ef2f8372be4f7e433e6a59fa.tar.gz
nextcloud-server-a9575a7029f21226ef2f8372be4f7e433e6a59fa.zip
handle cases where the hash context gets cleaned up before the hash wrapper
Signed-off-by: Robin Appelman <robin@icewind.nl>
-rw-r--r--lib/private/Files/Stream/HashWrapper.php6
1 files changed, 5 insertions, 1 deletions
diff --git a/lib/private/Files/Stream/HashWrapper.php b/lib/private/Files/Stream/HashWrapper.php
index fd9bb3cdd0b..b2bfcff68d4 100644
--- a/lib/private/Files/Stream/HashWrapper.php
+++ b/lib/private/Files/Stream/HashWrapper.php
@@ -67,7 +67,11 @@ class HashWrapper extends Wrapper {
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;
}