From: Bob Weinand Date: Tue, 14 Oct 2014 07:16:30 +0000 (+0200) Subject: Fix invalid efree() on null pointer and add help for -x X-Git-Tag: php-5.6.3RC1~51^2~52^2~8 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=c812ee9c3556c0ea797627c86a0a650c65f9908b;p=php Fix invalid efree() on null pointer and add help for -x --- 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) {