From 21a4db917b9e5be79e47376d46e511ecc2e7a8b9 Mon Sep 17 00:00:00 2001 From: Mathieu Desnoyers Date: Wed, 26 Jul 2017 12:06:53 -0400 Subject: [PATCH] Fix: Dereference null return value MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Found by Coverity: 2. returned_null: bt_ctf_field_type_variant_get_tag_name returns null (checked 4 out of 5 times). 3. var_assigned: Assigning: pathstr = null return value from bt_ctf_field_type_variant_get_tag_name. CID 1376176 (#1 of 1): Dereference null return value (NULL_RETURNS). dereference: Dereferencing a pointer that might be null pathstr when calling pathstr_to_field_path. Signed-off-by: Mathieu Desnoyers Signed-off-by: Jérémie Galarneau --- lib/ctf-ir/resolve.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/lib/ctf-ir/resolve.c b/lib/ctf-ir/resolve.c index b4a9c58c..c8648254 100644 --- a/lib/ctf-ir/resolve.c +++ b/lib/ctf-ir/resolve.c @@ -1023,6 +1023,12 @@ int resolve_sequence_or_variant_type(struct bt_ctf_field_type *type, abort(); } + if (!pathstr) { + BT_LOGW_STR("Cannot get path string."); + ret = -1; + goto end; + } + /* Get target field path out of path string */ target_field_path = pathstr_to_field_path(pathstr, ctx); if (!target_field_path) { -- 2.34.1