aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPřemysl Janouch <p.janouch@gmail.com>2015-02-22 21:30:30 +0100
committerPřemysl Janouch <p.janouch@gmail.com>2015-02-22 21:30:30 +0100
commitf6f66c90215180654cedf1c900560944a5ecef9b (patch)
treec90e06f7b9c8770577e3725aa4ec498d0a53e7ca
parentf468fdf3432e198a4a93965e7002a3d7f976b467 (diff)
downloadjson-rpc-shell-f6f66c90215180654cedf1c900560944a5ecef9b.tar.gz
json-rpc-shell-f6f66c90215180654cedf1c900560944a5ecef9b.tar.xz
json-rpc-shell-f6f66c90215180654cedf1c900560944a5ecef9b.zip
Fix a leak and a null pointer dereference
-rw-r--r--json-rpc-shell.c15
1 files changed, 10 insertions, 5 deletions
diff --git a/json-rpc-shell.c b/json-rpc-shell.c
index 6e8a4f6..2dfd4ed 100644
--- a/json-rpc-shell.c
+++ b/json-rpc-shell.c
@@ -169,16 +169,19 @@ vprint_attributed (struct app_context *ctx,
if (!attribute)
printer = NULL;
- const char *value;
- value = str_map_find (&ctx->config, attribute);
- if (printer && soft_assert (value))
+ if (printer)
+ {
+ const char *value = str_map_find (&ctx->config, attribute);
tputs (value, 1, printer);
+ }
vfprintf (stream, fmt, ap);
- value = str_map_find (&ctx->config, ATTR_RESET);
- if (printer && soft_assert (value))
+ if (printer)
+ {
+ const char *value = str_map_find (&ctx->config, ATTR_RESET);
tputs (value, 1, printer);
+ }
}
static void
@@ -465,6 +468,8 @@ parse_response (struct app_context *ctx, struct str *buf)
char *utf8 = xstrdup_printf ("error response: %" JSON_INTEGER_FORMAT
" (%s)", code_val, json_string_value (message));
char *s = iconv_xstrdup (ctx->term_from_utf8, utf8, -1, NULL);
+ free (utf8);
+
if (!s)
print_error ("character conversion failed for `%s'", "error");
else