From 3445e0e59ed8d3852664532f345e924f7100a54a Mon Sep 17 00:00:00 2001 From: Bob Weinand Date: Sat, 11 Oct 2014 00:20:30 +0200 Subject: [PATCH] Fix issue krakjoe/phpdbg#122 (segfault in helpaliases) --- phpdbg_help.c | 6 +++--- phpdbg_utils.c | 6 ++++-- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/phpdbg_help.c b/phpdbg_help.c index 3adc38b6ae..29087e005d 100644 --- a/phpdbg_help.c +++ b/phpdbg_help.c @@ -265,10 +265,10 @@ PHPDBG_HELP(aliases) /* {{{ */ /* Print out aliases for all commands except help as this one comes last */ phpdbg_writeln("help", "", "Below are the aliased, short versions of all supported commands"); - phpdbg_xml(""); + phpdbg_xml(""); for(c = phpdbg_prompt_commands; c->name; c++) { if (c->alias && c->alias != 'h') { - phpdbg_writeln("command", "name=\"%s\" alias=\"%c\" tip=\"%s\"", " %c %-20s %s", c->alias, c->name, c->tip); + phpdbg_writeln("command", "alias=\"%c\" name=\"%s\" tip=\"%s\"", " %c %-20s %s", c->alias, c->name, c->tip); if (c->subs) { len = 20 - 1 - c->name_len; for(c_sub = c->subs; c_sub->alias; c_sub++) { @@ -285,7 +285,7 @@ PHPDBG_HELP(aliases) /* {{{ */ /* Print out aliases for help as this one comes last, with the added text on how aliases are used */ get_command("h", 1, &c, phpdbg_prompt_commands TSRMLS_CC); - phpdbg_writeln("aliasinfo", "alias=\"%c\" name=\"%-*s\" tip=\"%s\"", " %c %-20s %s\n", c->alias, c->name, c->tip); + phpdbg_writeln("aliasinfo", "alias=\"%c\" name=\"%s\" tip=\"%s\"", " %c %-20s %s\n", c->alias, c->name, c->tip); phpdbg_xml(""); diff --git a/phpdbg_utils.c b/phpdbg_utils.c index 11e3a52a23..c631d8f525 100644 --- a/phpdbg_utils.c +++ b/phpdbg_utils.c @@ -772,8 +772,8 @@ static int format_converter(register buffy *odp, const char *fmt, zend_bool esca s_len = precision; } } else { - s = S_NULL; - s_len = S_NULL_LEN; + s = ""; + s_len = 0; } pad_char = ' '; break; @@ -1279,6 +1279,8 @@ PHPDBG_API int phpdbg_vprint(int type TSRMLS_DC, int fd, const char *tag, const va_copy(argcpy, args); xmllen = phpdbg_xml_vasprintf(&xml, xmlfmt, 1, argcpy TSRMLS_CC); va_end(argcpy); + } else { + xml = estrdup(""); } } -- 2.40.0