Make options_tostring allocate its result instead of using a stack

buffer (needed for something in the future).
This commit is contained in:
nicm
2019-04-25 18:18:55 +00:00
parent 1677bb0dea
commit 32a81e197b
4 changed files with 32 additions and 41 deletions

View File

@ -162,8 +162,8 @@ cmd_show_options_print(struct cmd *self, struct cmdq_item *item,
struct options_entry *o, int idx)
{
struct options_array_item *a;
const char *name, *value;
char *tmp, *escaped;
const char *name;
char *value, *tmp, *escaped;
if (idx != -1) {
xasprintf(&tmp, "%s[%d]", options_name(o), idx);
@ -191,6 +191,7 @@ cmd_show_options_print(struct cmd *self, struct cmdq_item *item,
free(escaped);
} else
cmdq_print(item, "%s %s", name, value);
free(value);
free(tmp);
}