]> source.dussan.org Git - nextcloud-server.git/commitdiff
handle cases where the hash context gets cleaned up before the hash wrapper 33774/head
authorRobin Appelman <robin@icewind.nl>
Wed, 31 Aug 2022 13:05:10 +0000 (15:05 +0200)
committerRobin Appelman <robin@icewind.nl>
Wed, 31 Aug 2022 13:05:10 +0000 (15:05 +0200)
Signed-off-by: Robin Appelman <robin@icewind.nl>
lib/private/Files/Stream/HashWrapper.php

index fd9bb3cdd0b84c515516673b1aaec6c972365a75..b2bfcff68d4bab475103a65886e49d77db24a25d 100644 (file)
@@ -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;
                }