From: Mathieu Desnoyers Date: Wed, 26 Jul 2017 16:06:53 +0000 (-0400) Subject: Fix: Dereference null return value X-Git-Url: http://git.efficios.com/?p=babeltrace.git;a=commitdiff_plain;h=21a4db917b9e5be79e47376d46e511ecc2e7a8b9 Fix: Dereference null return value 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 --- 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) {