From: Jérémie Galarneau Date: Sat, 17 Dec 2016 17:11:29 +0000 (-0500) Subject: Fix: passing NULL to glib mapped file unref function is not allowed X-Git-Tag: v2.0.0-pre1~595 X-Git-Url: http://git.efficios.com/?p=babeltrace.git;a=commitdiff_plain;h=06367fa30be84b87781b591ce53074536d44744d Fix: passing NULL to glib mapped file unref function is not allowed Signed-off-by: Jérémie Galarneau --- diff --git a/plugins/ctf/fs/data-stream.c b/plugins/ctf/fs/data-stream.c index cd414c5c..949c2c3a 100644 --- a/plugins/ctf/fs/data-stream.c +++ b/plugins/ctf/fs/data-stream.c @@ -217,6 +217,10 @@ int build_index_from_idx_file(struct ctf_fs_stream *stream) index_file_path = g_build_filename(directory, "index", index_basename->str, NULL); mapped_file = g_mapped_file_new(index_file_path, FALSE, NULL); + if (!mapped_file) { + ret = -1; + goto end; + } filesize = g_mapped_file_get_length(mapped_file); if (filesize < sizeof(*header)) { printf_error("Invalid LTTng trace index: file size < header size"); @@ -294,8 +298,12 @@ end: g_free(directory); g_free(basename); g_free(index_file_path); - g_string_free(index_basename, TRUE); - g_mapped_file_unref(mapped_file); + if (index_basename) { + g_string_free(index_basename, TRUE); + } + if (mapped_file) { + g_mapped_file_unref(mapped_file); + } return ret; invalid_index: g_array_free(stream->index.entries, TRUE);