Fix: passing NULL to glib mapped file unref function is not allowed
authorJérémie Galarneau <jeremie.galarneau@efficios.com>
Sat, 17 Dec 2016 17:11:29 +0000 (12:11 -0500)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Sat, 27 May 2017 18:09:08 +0000 (14:09 -0400)
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
plugins/ctf/fs/data-stream.c

index cd414c5c1f991e2c084ae44e874d495fd302620a..949c2c3acd04b6ca0d95412e11554b5907d51583 100644 (file)
@@ -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);
This page took 0.025036 seconds and 4 git commands to generate.