]> granicus.if.org Git - php/commitdiff
Fixed segfault when listing and last line is empty
authorBob Weinand <bobwei9@hotmail.com>
Thu, 9 Oct 2014 10:43:53 +0000 (12:43 +0200)
committerBob Weinand <bobwei9@hotmail.com>
Thu, 9 Oct 2014 10:43:53 +0000 (12:43 +0200)
phpdbg_list.c

index 83c27bcfbca800f56cb5526aaf0c0e439f69b692..365c7a62e8c43637f97261ac4c51f0ca9f6c0ad7 100644 (file)
@@ -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);