From: Bert Vermeulen Date: Thu, 2 Oct 2014 11:51:19 +0000 (+0200) Subject: input: Avoid NULL dereference. X-Git-Tag: libsigrok-0.4.0~907 X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=640982114329b28aaca3390913037eddd8c6d550;p=libsigrok.git input: Avoid NULL dereference. This cleans up a warning generated by clang's static analyzer. --- diff --git a/src/input/input.c b/src/input/input.c index 4b0804a5..3c7fd516 100644 --- a/src/input/input.c +++ b/src/input/input.c @@ -271,15 +271,17 @@ SR_API struct sr_input *sr_input_new(const struct sr_input_module *imod, if (in->module->init && in->module->init(in, new_opts) != SR_OK) { g_free(in); in = NULL; + } else { + in->buf = g_string_sized_new(128); } + if (new_opts) g_hash_table_destroy(new_opts); - in->buf = g_string_sized_new(128); return in; } -/* Returns TRUE is all required meta items are available. */ +/* Returns TRUE if all required meta items are available. */ static gboolean check_required_metadata(const uint8_t *metadata, uint8_t *avail) { int m, a;