From c812ee9c3556c0ea797627c86a0a650c65f9908b Mon Sep 17 00:00:00 2001 From: Bob Weinand Date: Tue, 14 Oct 2014 09:16:30 +0200 Subject: [PATCH] Fix invalid efree() on null pointer and add help for -x --- phpdbg_help.c | 5 +++-- phpdbg_utils.c | 10 +++++++--- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/phpdbg_help.c b/phpdbg_help.c index 29087e005d..2990edd16d 100644 --- a/phpdbg_help.c +++ b/phpdbg_help.c @@ -133,10 +133,10 @@ void pretty_print(char *text TSRMLS_DC) *q++ = '\0'; if ((q-new)>size) { - phpdbg_error("help", "overrun=\"%lu\"", "Output overrun of %lu bytes", ((q-new) - size)); + phpdbg_error("help", "overrun=\"%lu\"", "Output overrun of %lu bytes", ((q - new) - size)); } - phpdbg_out("%s", new); + phpdbg_out("%s\n", new); efree(new); } /* }}} */ @@ -387,6 +387,7 @@ phpdbg_help_text_t phpdbg_help_text[] = { " **-S** **-S**cli Override SAPI name, careful!" CR " **-l** **-l**4000 Setup remote console ports" CR " **-a** **-a**192.168.0.3 Setup remote console bind address" CR +" **-x** Enable xml output (instead of normal text output)" CR " **-V** Print version number" CR " **--** **--** arg1 arg2 Use to delimit phpdbg arguments and php $argv; append any $argv " "argument after it" CR CR diff --git a/phpdbg_utils.c b/phpdbg_utils.c index c631d8f525..27b75b24ae 100644 --- a/phpdbg_utils.c +++ b/phpdbg_utils.c @@ -1290,8 +1290,10 @@ PHPDBG_API int phpdbg_vprint(int type TSRMLS_DC, int fd, const char *tag, const PHPDBG_G(err_buf).tag = estrdup(tag); PHPDBG_G(err_buf).msg = msg; PHPDBG_G(err_buf).msglen = msglen; - PHPDBG_G(err_buf).xml = xml; - PHPDBG_G(err_buf).xmllen = xmllen; + if (PHPDBG_G(flags) & PHPDBG_WRITE_XML) { + PHPDBG_G(err_buf).xml = xml; + PHPDBG_G(err_buf).xmllen = xmllen; + } return msglen; } @@ -1318,7 +1320,9 @@ PHPDBG_API void phpdbg_free_err_buf(TSRMLS_D) { efree(PHPDBG_G(err_buf).tag); efree(PHPDBG_G(err_buf).msg); - efree(PHPDBG_G(err_buf).xml); + if (PHPDBG_G(flags) & PHPDBG_WRITE_XML) { + efree(PHPDBG_G(err_buf).xml); + } } PHPDBG_API void phpdbg_activate_err_buf(zend_bool active TSRMLS_DC) { -- 2.50.1