From: Bob Weinand Date: Thu, 9 Oct 2014 10:43:53 +0000 (+0200) Subject: Fixed segfault when listing and last line is empty X-Git-Tag: php-5.6.3RC1~51^2~52^2~15 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=a54de936d028033304f385947fd67d69ae813fc5;p=php Fixed segfault when listing and last line is empty --- diff --git a/phpdbg_list.c b/phpdbg_list.c index 83c27bcfbc..365c7a62e8 100644 --- a/phpdbg_list.c +++ b/phpdbg_list.c @@ -162,7 +162,7 @@ void phpdbg_list_file(const char *filename, uint count, uint offset, uint highli } } - if (*(buffer + linelen - 1) != '\n') { + if (*(buffer + linelen - 1) != '\n' || !linelen) { phpdbg_out("\n"); } } @@ -265,8 +265,9 @@ zend_op_array *phpdbg_compile_file(zend_file_handle *file, int type TSRMLS_DC) { dataptr->line[++line] = (uint)(bufptr - data.buf) + 1; } } - dataptr = erealloc(dataptr, sizeof(phpdbg_file_source) + sizeof(uint) * line); dataptr->lines = ++line; + dataptr->line[line] = endptr - data.buf; + dataptr = erealloc(dataptr, sizeof(phpdbg_file_source) + sizeof(uint) * line); ret = PHPDBG_G(compile_file)(&fake, type TSRMLS_CC);