1
0
mirror of https://github.com/php/php-src.git synced 2026-04-29 19:23:22 +02:00

Fixed memory corruption

This commit is contained in:
Dmitry Stogov
2005-12-22 07:54:19 +00:00
parent da08d0ffd5
commit 9faaef0d08
+15 -5
View File
@@ -92,7 +92,7 @@ PHP_MINFO_FUNCTION(ctype)
/* {{{ 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 @@ PHP_MINFO_FUNCTION(ctype)
} 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; \