Avoid leaking file descriptor when looking for binary files
authorChristophe Coevoet <stof@notk.org>
Fri, 6 Nov 2015 09:23:40 +0000 (10:23 +0100)
committerChristian Weiske <cweiske@cweiske.de>
Tue, 10 Nov 2015 05:32:35 +0000 (06:32 +0100)
src/phorkie/File.php

index cf5daae..97ae47e 100644 (file)
@@ -200,9 +200,12 @@ class File
         while (false !== ($char = fgetc($fp)) && ++$pos < 100) {
             $data .= $char;
             if (!$hasMb && ord($char) > 128) {
+                fclose($fp);
                 return false;
             }
         }
+        fclose($fp);
+
         if (!$hasMb) {
             return true;
         }