helly           Fri Feb 14 14:46:21 2003 EDT

  Modified files:              (Branch: PHP_4_3)
    /php4/ext/standard  image.c 
  Log:
  MFH: xbm improvements
  
Index: php4/ext/standard/image.c
diff -u php4/ext/standard/image.c:1.72.2.9 php4/ext/standard/image.c:1.72.2.10
--- php4/ext/standard/image.c:1.72.2.9  Thu Feb 13 02:16:55 2003
+++ php4/ext/standard/image.c   Fri Feb 14 14:46:21 2003
@@ -17,7 +17,7 @@
    +----------------------------------------------------------------------+
  */
 
-/* $Id: image.c,v 1.72.2.9 2003/02/13 07:16:55 sniper Exp $ */
+/* $Id: image.c,v 1.72.2.10 2003/02/14 19:46:21 helly Exp $ */
 
 #include "php.h"
 #include <stdio.h>
@@ -956,11 +956,10 @@
 
 /* {{{ php_get_xbm
  */
-#define MAX_XBM_LINE_SIZE 255
 static int php_get_xbm(php_stream *stream, struct gfxinfo **result TSRMLS_DC)
 {
-    char fline[MAX_XBM_LINE_SIZE];
-    char iname[MAX_XBM_LINE_SIZE];
+    char *fline;
+    char *iname;
     char *type;
     int value;
     unsigned int width = 0, height = 0;
@@ -971,12 +970,8 @@
        if (php_stream_rewind(stream)) {
                return 0;
        }
-       while (php_stream_gets(stream, fline, MAX_XBM_LINE_SIZE)) {
-               fline[MAX_XBM_LINE_SIZE-1] = '\0';
-               if (strlen(fline) == MAX_XBM_LINE_SIZE-1) {
-                       return 0;
-               }
-       
+       while ((fline=php_stream_gets(stream, NULL, 0)) != NULL) {
+               iname = estrdup(fline); /* simple way to get necessary buffer of 
+required size */
                if (sscanf(fline, "#define %s %d", iname, &value) == 2) {
                        if (!(type = strrchr(iname, '_'))) {
                                type = iname;
@@ -987,16 +982,23 @@
                        if (!strcmp("width", type)) {
                                width = (unsigned int) value;
                                if (height) {
+                                       efree(iname);
                                        break;
                                }
                        }
                        if (!strcmp("height", type)) {
                                height = (unsigned int) value;
                                if (width) {
+                                       efree(iname);
                                        break;
                                }
                        }
                }
+               efree(fline);
+               efree(iname);
+       }
+       if (fline) {
+               efree(fline);
        }
 
        if (width && height) {



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

Reply via email to