helly           Wed Feb 23 17:49:32 2005 EDT

  Modified files:              
    /php-src/ext/standard       image.c 
  Log:
  - Slightly redesign
  # More to follow, explanation follows at more public place
  
  
http://cvs.php.net/diff.php/php-src/ext/standard/image.c?r1=1.102&r2=1.103&ty=u
Index: php-src/ext/standard/image.c
diff -u php-src/ext/standard/image.c:1.102 php-src/ext/standard/image.c:1.103
--- php-src/ext/standard/image.c:1.102  Mon Oct  4 16:42:30 2004
+++ php-src/ext/standard/image.c        Wed Feb 23 17:49:32 2005
@@ -17,7 +17,7 @@
    +----------------------------------------------------------------------+
  */
 
-/* $Id: image.c,v 1.102 2004/10/04 20:42:30 iliaa Exp $ */
+/* $Id: image.c,v 1.103 2005/02/23 22:49:32 helly Exp $ */
 
 #include "php.h"
 #include <stdio.h>
@@ -866,38 +866,41 @@
        int chunkId;
        int size;
 
-       if (php_stream_read(stream, a, 8) != 8)
+       if (php_stream_read(stream, a, 8) != 8) {
                return NULL;
-       if (strncmp(a+4, "ILBM", 4) && strncmp(a+4, "PBM ", 4))
+       }
+       if (strncmp(a+4, "ILBM", 4) && strncmp(a+4, "PBM ", 4)) {
                return NULL;
-
-       result = (struct gfxinfo *) ecalloc(1, sizeof(struct gfxinfo));
+       }
 
        /* loop chunks to find BMHD chunk */
        do {
                if (php_stream_read(stream, a, 8) != 8) {
-                       efree(result);
                        return NULL;
                }
                chunkId = php_ifd_get32s(a+0, 1);
                size    = php_ifd_get32s(a+4, 1);
+               if (size < 0) {
+                       return NULL;
+               }
                if ((size & 1) == 1) {
                        size++;
                }
                if (chunkId == 0x424d4844) { /* BMHD chunk */
                        if (php_stream_read(stream, a, 9) != 9) {
-                               efree(result);
                                return NULL;
                        }
+                       result = (struct gfxinfo *) ecalloc(1, sizeof(struct 
gfxinfo));
                        result->width    = php_ifd_get16s(a+0, 1);
                        result->height   = php_ifd_get16s(a+2, 1);
                        result->bits     = a[8] & 0xff;
                        result->channels = 0;
-                       if (result->width > 0 && result->height > 0 && 
result->bits > 0 && result->bits < 33)
+                       if (result->width > 0 && result->height > 0 && 
result->bits > 0 && result->bits < 33) {
                                return result;
+                       }
+                       efree(result);
                } else {
                        if (php_stream_seek(stream, size, SEEK_CUR)) {
-                               efree(result);
                                return NULL;
                        }
                }

-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to