Bladeren bron

Fix potential memory leak due to not calling imagedestroy on GdImage objects

Emelia Smith 1 jaar geleden
bovenliggende
commit
74ad26fee6
2 gewijzigde bestanden met toevoegingen van 7 en 1 verwijderingen
  1. 3 0
      app/Services/InstanceService.php
  2. 4 1
      app/Util/Media/Blurhash.php

+ 3 - 0
app/Services/InstanceService.php

@@ -120,6 +120,9 @@ class InstanceService
 				$pixels[] = $row;
 			}
 
+			// Free the allocated GdImage object from memory:
+			imagedestroy($image);
+
 			$components_x = 4;
 			$components_y = 4;
 			$blurhash = Blurhash::encode($pixels, $components_x, $components_y);

+ 4 - 1
app/Util/Media/Blurhash.php

@@ -44,6 +44,9 @@ class Blurhash {
 			$pixels[] = $row;
 		}
 
+		// Free the allocated GdImage object from memory:
+		imagedestroy($image);
+
 		$components_x = 4;
 		$components_y = 4;
 		$blurhash = BlurhashEngine::encode($pixels, $components_x, $components_y);
@@ -53,4 +56,4 @@ class Blurhash {
 		return $blurhash;
 	}
 
-}
+}