summaryrefslogtreecommitdiff
path: root/sapi/phpdbg/phpdbg_prompt.c
diff options
context:
space:
mode:
authorBob Weinand <bobwei9@hotmail.com>2016-12-20 20:18:36 +0100
committerBob Weinand <bobwei9@hotmail.com>2016-12-20 20:18:36 +0100
commit8b06b7e2665e16d1643f7027072dfd3ec34fa0e2 (patch)
treef192e165a69229220286274ff1244751ae6b88d4 /sapi/phpdbg/phpdbg_prompt.c
parent3273f154120696c8054f61e8371a0c0af067fb36 (diff)
downloadphp-git-8b06b7e2665e16d1643f7027072dfd3ec34fa0e2.tar.gz
Fixed bug #73794 (Crash (out of memory) when using run and # command separator)
Diffstat (limited to 'sapi/phpdbg/phpdbg_prompt.c')
-rw-r--r--sapi/phpdbg/phpdbg_prompt.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/sapi/phpdbg/phpdbg_prompt.c b/sapi/phpdbg/phpdbg_prompt.c
index da2cdfb738..822f25f005 100644
--- a/sapi/phpdbg/phpdbg_prompt.c
+++ b/sapi/phpdbg/phpdbg_prompt.c
@@ -803,10 +803,13 @@ PHPDBG_COMMAND(run) /* {{{ */
if (param && param->type != EMPTY_PARAM && param->len != 0) {
char **argv = emalloc(5 * sizeof(char *));
char *end = param->str + param->len, *p = param->str;
+ char last_byte;
int argc = 0;
int i;
while (*end == '\r' || *end == '\n') *(end--) = 0;
+ last_byte = end[1];
+ end[1] = 0;
while (*p == ' ') p++;
while (*p) {
@@ -870,6 +873,7 @@ free_cmd:
efree(argv[i]);
}
efree(argv);
+ end[1] = last_byte;
return SUCCESS;
}
@@ -880,6 +884,8 @@ free_cmd:
do p++; while (*p == ' ');
}
}
+ end[1] = last_byte;
+
argv[0] = SG(request_info).argv[0];
for (i = SG(request_info).argc; --i;) {
efree(SG(request_info).argv[i]);