Fix: ds_file_munmap must check ds_file for NULL
[babeltrace.git] / plugins / ctf / fs-src / data-stream-file.c
index bf3dda60839051fa614f900196e1cda1d32a8964..94f2b9b3edfb1c563eaeb4d35801a71b5cd2cf89 100644 (file)
@@ -22,6 +22,7 @@
  * SOFTWARE.
  */
 
+#include <stdlib.h>
 #include <stdio.h>
 #include <stdint.h>
 #include <stdlib.h>
@@ -55,12 +56,13 @@ static
 int ds_file_munmap(struct ctf_fs_ds_file *ds_file)
 {
        int ret = 0;
-       struct ctf_fs_component *ctf_fs = ds_file->file->ctf_fs;
+       struct ctf_fs_component *ctf_fs;
 
-       if (!ds_file->mmap_addr) {
+       if (!ds_file || !ds_file->mmap_addr) {
                goto end;
        }
 
+       ctf_fs = ds_file->file->ctf_fs;
        if (munmap(ds_file->mmap_addr, ds_file->mmap_len)) {
                PERR("Cannot memory-unmap address %p (size %zu) of file \"%s\" (%p): %s\n",
                        ds_file->mmap_addr, ds_file->mmap_len,
@@ -465,7 +467,7 @@ struct bt_notification_iterator_next_return ctf_fs_ds_file_next(
                 * medium-specific; there is nothing for the user to do
                 * and it should have been handled upstream.
                 */
-               assert(false);
+               abort();
        case BT_CTF_NOTIF_ITER_STATUS_INVAL:
        case BT_CTF_NOTIF_ITER_STATUS_ERROR:
        default:
@@ -498,7 +500,7 @@ int ctf_fs_ds_file_get_packet_header_context_fields(
        case BT_CTF_NOTIF_ITER_STATUS_OK:
                break;
        case BT_CTF_NOTIF_ITER_STATUS_AGAIN:
-               assert(false);
+               abort();
        case BT_CTF_NOTIF_ITER_STATUS_INVAL:
        case BT_CTF_NOTIF_ITER_STATUS_ERROR:
        default:
This page took 0.024287 seconds and 4 git commands to generate.