From 0c3fc300a709ec7aab672d6a186e895198ff755d Mon Sep 17 00:00:00 2001
From: "yogeshwar.g" <yogeshwar.g@vtigersolutions.com>
Date: Fri, 12 Jan 2024 13:24:21 +0530
Subject: [PATCH] Fixes::157000819::yogeshwar::re-Fixed

---
 kcfinder/lib/class_gd.php | 13 +++++++++----
 1 file changed, 9 insertions(+), 4 deletions(-)

diff --git a/kcfinder/lib/class_gd.php b/kcfinder/lib/class_gd.php
index adfc89784..0ac2aaea9 100644
--- a/kcfinder/lib/class_gd.php
+++ b/kcfinder/lib/class_gd.php
@@ -52,8 +52,13 @@ class gd {
             $height = @imagesy($image);
 
         } elseif (is_array($image)) {
-            list($key, $width) = each($image);
-            list($key, $height) = each($image);
+            $key = key($image);
+            $width = current($image);
+            next($image);
+
+            $key = key($image);
+            $height = current($image);
+            next($image);
             $image = imagecreatetruecolor($width, $height);
 
         } elseif (false !== (list($width, $height, $type) = @getimagesize($image))) {
@@ -71,8 +76,8 @@ class gd {
         }
 
         $return = (
-            is_resource($image) &&
-            (get_resource_type($image) == "gd") &&
+            ((is_resource($image) && get_resource_type($image) === 'gd') ||
+            (is_object($image) && $image instanceof \GDImage)) &&
             isset($width) &&
             isset($height) &&
             (preg_match('/^[1-9][0-9]*$/', $width) !== false) &&
-- 
GitLab