X-Git-Url: http://git.efficios.com/?a=blobdiff_plain;f=formats%2Fctf%2Fctf.c;h=40da01da2d57619d1257fc42a4666923afaaeaa2;hb=de52f946293c27220e1b63f3da5d4f068fd43479;hp=58b5488920d006e71aafe96b764e5f49ec7c5b6d;hpb=543409b06210e4f5545758941025e9eb439affe4;p=babeltrace.git diff --git a/formats/ctf/ctf.c b/formats/ctf/ctf.c index 58b54889..40da01da 100644 --- a/formats/ctf/ctf.c +++ b/formats/ctf/ctf.c @@ -1964,6 +1964,11 @@ int ctf_open_file_stream_read(struct ctf_trace *td, const char *path, int flags, ret = 0; goto fd_is_dir_ok; } + if (!statbuf.st_size) { + /** Skip empty files. */ + ret = 0; + goto fd_is_empty_file; + } file_stream = g_new0(struct ctf_file_stream, 1); file_stream->pos.last_offset = LAST_OFFSET_POISON; @@ -1998,6 +2003,7 @@ int ctf_open_file_stream_read(struct ctf_trace *td, const char *path, int flags, index_name = malloc((strlen(path) + sizeof(INDEX_PATH)) * sizeof(char)); if (!index_name) { fprintf(stderr, "[error] Cannot allocate index filename\n"); + ret = -ENOMEM; goto error_def; } snprintf(index_name, strlen(path) + sizeof(INDEX_PATH), @@ -2056,6 +2062,7 @@ error_def: fprintf(stderr, "Error on ctf_fini_pos\n"); } g_free(file_stream); +fd_is_empty_file: fd_is_dir_ok: fstat_error: closeret = close(fd);