Skip to content

Commit 8b06b7e

Browse files
committed
Fixed bug #73794 (Crash (out of memory) when using run and # command separator)
1 parent 3273f15 commit 8b06b7e

File tree

3 files changed

+21
-0
lines changed

3 files changed

+21
-0
lines changed

NEWS

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,10 @@ PHP NEWS
3939
. Fixed bug #72931 (PDO_FIREBIRD with Firebird 3.0 not work on returning
4040
statement). (Dorin Marcoci)
4141

42+
- phpdbg:
43+
. Fixed bug #73794 (Crash (out of memory) when using run and # command
44+
separator). (Bob)
45+
4246
- Standard:
4347
. Fixed bug #73594 (dns_get_record does not populate $additional out parameter).
4448
(Bruce Weirdan)

sapi/phpdbg/phpdbg_prompt.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -803,10 +803,13 @@ PHPDBG_COMMAND(run) /* {{{ */
803803
if (param && param->type != EMPTY_PARAM && param->len != 0) {
804804
char **argv = emalloc(5 * sizeof(char *));
805805
char *end = param->str + param->len, *p = param->str;
806+
char last_byte;
806807
int argc = 0;
807808
int i;
808809

809810
while (*end == '\r' || *end == '\n') *(end--) = 0;
811+
last_byte = end[1];
812+
end[1] = 0;
810813

811814
while (*p == ' ') p++;
812815
while (*p) {
@@ -870,6 +873,7 @@ PHPDBG_COMMAND(run) /* {{{ */
870873
efree(argv[i]);
871874
}
872875
efree(argv);
876+
end[1] = last_byte;
873877
return SUCCESS;
874878
}
875879

@@ -880,6 +884,8 @@ PHPDBG_COMMAND(run) /* {{{ */
880884
do p++; while (*p == ' ');
881885
}
882886
}
887+
end[1] = last_byte;
888+
883889
argv[0] = SG(request_info).argv[0];
884890
for (i = SG(request_info).argc; --i;) {
885891
efree(SG(request_info).argv[i]);

sapi/phpdbg/tests/bug73794.phpt

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
--TEST--
2+
Bug #73794 (Crash (out of memory) when using run and # command separator)
3+
--PHPDBG--
4+
r echo # quit
5+
--EXPECTF--
6+
[Successful compilation of %s]
7+
prompt> echo
8+
--FILE--
9+
<?php
10+
echo $argv[1];
11+
?>

0 commit comments

Comments
 (0)