From 6479e4049651c80009878e1c2300ec8f0f0ef18d Mon Sep 17 00:00:00 2001 From: ghost Date: Fri, 12 Jan 2024 18:40:21 +0200 Subject: [PATCH] add socket connection closers --- src/Xash3D/Master.php | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/src/Xash3D/Master.php b/src/Xash3D/Master.php index 541c421..e6a1d0d 100644 --- a/src/Xash3D/Master.php +++ b/src/Xash3D/Master.php @@ -65,6 +65,10 @@ class Master // Skip header if (!fread($this->_socket, 6)) { + fclose( + $this->_socket + ); + return null; } @@ -76,6 +80,10 @@ class Master // Get host if (false === $host = fread($this->_socket, 16)) { + fclose( + $this->_socket + ); + return null; } @@ -94,12 +102,20 @@ class Master // Decode first byte for port if (false === $byte1 = fread($this->_socket, 1)) { + fclose( + $this->_socket + ); + return null; } // Decode second byte for port if (false === $byte2 = fread($this->_socket, 1)) { + fclose( + $this->_socket + ); + return null; } @@ -123,6 +139,11 @@ class Master ]; } + // Close connection + fclose( + $this->_socket + ); + return $servers; } } \ No newline at end of file