From a54de936d028033304f385947fd67d69ae813fc5 Mon Sep 17 00:00:00 2001 From: Bob Weinand Date: Thu, 9 Oct 2014 12:43:53 +0200 Subject: [PATCH] Fixed segfault when listing and last line is empty --- phpdbg_list.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) 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); -- 2.40.0