Fix invalid efree() on null pointer and add help for -x
authorBob Weinand <bobwei9@hotmail.com>
Tue, 14 Oct 2014 07:16:30 +0000 (09:16 +0200)
committerBob Weinand <bobwei9@hotmail.com>
Tue, 14 Oct 2014 07:16:30 +0000 (09:16 +0200)
phpdbg_help.c
phpdbg_utils.c

index 29087e005df156d6ef7e05ab9735c0c428a61284..2990edd16d3e80b2091449b034fce4095682d62d 100644 (file)
@@ -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
index c631d8f52560e1ab27bb81f6f12bd85ea906a62e..27b75b24ae40970c242cfa02d4b91b3955ba7e03 100644 (file)
@@ -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) {