Skip to content

Commit

Permalink
Fix bug #73807
Browse files Browse the repository at this point in the history
  • Loading branch information
nikic authored and smalyshev committed Jun 20, 2017
1 parent 0e21d80 commit 0f8cf3b
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions main/php_variables.c
Original file line number Diff line number Diff line change
Expand Up @@ -237,11 +237,14 @@ typedef struct post_var_data {
char *ptr;
char *end;
uint64_t cnt;

/* Bytes in ptr that have already been scanned for '&' */
size_t already_scanned;
} post_var_data_t;

static zend_bool add_post_var(zval *arr, post_var_data_t *var, zend_bool eof TSRMLS_DC)
{
char *ksep, *vsep, *val;
char *start, *ksep, *vsep, *val;
size_t klen, vlen;
/* FIXME: string-size_t */
unsigned int new_vlen;
Expand All @@ -250,9 +253,11 @@ static zend_bool add_post_var(zval *arr, post_var_data_t *var, zend_bool eof TSR
return 0;
}

vsep = memchr(var->ptr, '&', var->end - var->ptr);
start = var->ptr + var->already_scanned;
vsep = memchr(start, '&', var->end - start);
if (!vsep) {
if (!eof) {
var->already_scanned = var->end - var->ptr;
return 0;
} else {
vsep = var->end;
Expand Down Expand Up @@ -285,6 +290,7 @@ static zend_bool add_post_var(zval *arr, post_var_data_t *var, zend_bool eof TSR
efree(val);

var->ptr = vsep + (vsep != var->end);
var->already_scanned = 0;
return 1;
}

Expand All @@ -304,7 +310,7 @@ static inline int add_post_vars(zval *arr, post_var_data_t *vars, zend_bool eof
}
}

if (!eof) {
if (!eof && vars->str.c != vars->ptr) {
memmove(vars->str.c, vars->ptr, vars->str.len = vars->end - vars->ptr);
}
return SUCCESS;
Expand Down

0 comments on commit 0f8cf3b

Please sign in to comment.