dmitry          Thu Dec 22 07:54:19 2005 EDT

  Modified files:              
    /php-src/ext/ctype  ctype.c 
  Log:
  Fixed memory corruption
  
  
http://cvs.php.net/viewcvs.cgi/php-src/ext/ctype/ctype.c?r1=1.36&r2=1.37&diff_format=u
Index: php-src/ext/ctype/ctype.c
diff -u php-src/ext/ctype/ctype.c:1.36 php-src/ext/ctype/ctype.c:1.37
--- php-src/ext/ctype/ctype.c:1.36      Tue Dec  6 02:24:26 2005
+++ php-src/ext/ctype/ctype.c   Thu Dec 22 07:54:19 2005
@@ -92,7 +92,7 @@
 /* {{{ ctype
  */
 #define CTYPE(iswhat) \
-       zval *c; \
+       zval *c, tmp; \
        if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z", &c) == 
FAILURE) \
                return; \
        switch (Z_TYPE_P(c)) { \
@@ -102,23 +102,33 @@
                } else if (Z_LVAL_P(c) >= -128 && Z_LVAL_P(c) < 0) { \
                        RETURN_BOOL(iswhat(Z_LVAL_P(c) + 256)); \
                } \
-               SEPARATE_ZVAL(&c);      \
-               convert_to_string(c);   \
+               tmp = *c; \
+               zval_copy_ctor(&tmp); \
+               convert_to_string(&tmp); \
+               c = &tmp; \
        case IS_STRING: \
        case IS_BINARY: \
 string:\
                { \
                        char *p = Z_STRVAL_P(c), *e = Z_STRVAL_P(c) + 
Z_STRLEN_P(c); \
                        if (e == p) {   \
+                               if (c == &tmp) zval_dtor(&tmp); \
                                RETURN_FALSE;   \
                        }       \
                        while (p < e) { \
-                               if(!iswhat((int)*(unsigned char *)(p++))) 
RETURN_FALSE; \
+                               if(!iswhat((int)*(unsigned char *)(p++))) { \
+                                       if (c == &tmp) zval_dtor(&tmp); \
+                                       RETURN_FALSE; \
+                               } \
                        } \
+                       if (c == &tmp) zval_dtor(&tmp); \
                        RETURN_TRUE; \
                } \
        case IS_UNICODE: \
-               convert_to_string(c); \
+               tmp = *c; \
+               zval_copy_ctor(&tmp); \
+               convert_to_string(&tmp); \
+               c = &tmp; \
                goto string; \
        default: \
                break; \

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

Reply via email to