]> 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:51:04 +0000 (12:51 +0200)
Conflicts:
phpdbg_list.c

phpdbg_list.c

index 6a53b8d5e7d6a50047d7f2899237198bd280745f..5ea3a3efd8e76a9b56ecfeef175926f2a7dd1a72 100644 (file)
@@ -158,6 +158,10 @@ void phpdbg_list_file(const char *filename, uint count, uint offset, uint highli
                                phpdbg_write(">%05u: %.*s", line, linelen, buffer);
                        }
                }
+
+               if (*(buffer + linelen - 1) != '\n' || !linelen) {
+                       phpdbg_writeln(EMPTY);
+               }
        }
 } /* }}} */
 
@@ -256,8 +260,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);