XCF: suppress warning on unpack + early exit on error
authorAntoine Musso <hashar@users.mediawiki.org>
Fri, 6 Jan 2012 16:17:04 +0000 (16:17 +0000)
committerAntoine Musso <hashar@users.mediawiki.org>
Fri, 6 Jan 2012 16:17:04 +0000 (16:17 +0000)
follow r108141

includes/media/XCF.php

index 385e988..b113d70 100644 (file)
@@ -78,6 +78,7 @@ class XCFHandler extends BitmapHandler {
                #                         1: Grayscale
                #                         2: Indexed color
                #        (enum GimpImageBaseType in libgimpbase/gimpbaseenums.h)
+               wfSuppressWarnings();
                $header = unpack(
                          "A9magic"     # A: space padded
                        . "/a5version"  # a: zero padded
@@ -86,6 +87,11 @@ class XCFHandler extends BitmapHandler {
                        . "/Nbase_type" # /
                , $binaryHeader
                );
+               wfRestoreWarnings();
+
+               if( $header === false ) {
+                       return false;
+               }
 
                # Check values
                if( $header['magic'] !== 'gimp xcf' ) {