Browse Source

Fix the highlighting problem. STR_REALLOC() should be used instead of plain erealloc()

whenever you're dealing with strings that might be coming back from the engine - there seem
to be a few other places like this in PHP.
PHP-4.0.5
Zeev Suraski 26 years ago
parent
commit
f0888ccaef
  1. 2
      Zend/zend-scanner.l
  2. 8
      Zend/zend.h
  3. 4
      Zend/zend_compile.c
  4. 2
      Zend/zend_execute.c

2
Zend/zend-scanner.l

@ -409,7 +409,7 @@ static inline int prepare_string_for_scanning(zval *str CLS_DC)
{
#ifndef ZTS
/* enforce two trailing NULLs for flex... */
str->value.str.val = (char *) erealloc(str->value.str.val,str->value.str.len+2);
STR_REALLOC(str->value.str.val, str->value.str.len+2);
str->value.str.val[str->value.str.len+1]=0;

8
Zend/zend.h

@ -231,6 +231,14 @@ ZEND_API extern char *undefined_variable_string;
#define STR_FREE(ptr) if (ptr && ptr!=empty_string && ptr!=undefined_variable_string) { efree(ptr); }
#define STR_FREE_REL(ptr) if (ptr && ptr!=empty_string && ptr!=undefined_variable_string) { efree_rel(ptr); }
#define STR_REALLOC(ptr, size) \
if (ptr!=empty_string && ptr!=undefined_variable_string) { \
ptr = (char *) erealloc(ptr, size); \
} else { \
ptr = (char *) emalloc(size); \
memset(ptr, 0, size); \
}
/* output support */
#define ZEND_WRITE(str, str_len) zend_write((str), (str_len))
#define ZEND_PUTS(str) zend_write((str), strlen((str)))

4
Zend/zend_compile.c

@ -1251,9 +1251,9 @@ void do_switch_cond(znode *cond CLS_DC)
switch_entry.control_var = -1;
zend_stack_push(&CG(switch_cond_stack), (void *) &switch_entry, sizeof(switch_entry));
if (opline->result.op_type == IS_VAR) {
/* if (opline->result.op_type == IS_VAR) {
opline->result.u.EA.type |= EXT_TYPE_UNUSED;
}
}*/
do_begin_loop(CLS_C);

2
Zend/zend_execute.c

@ -1806,6 +1806,8 @@ send_by_ref:
if (!Ts[opline->op1.u.var].var.ptr_ptr) {
get_zval_ptr(&opline->op1, Ts, &EG(free_op1), BP_VAR_R);
FREE_OP(&opline->op1, EG(free_op1));
} else {
zval_ptr_dtor(&Ts[opline->op1.u.var].var.ptr);
}
break;
case IS_TMP_VAR:

Loading…
Cancel
Save