From 1c1ef10173fbcee3c78a82541a0c540bca8e1189 Mon Sep 17 00:00:00 2001 From: Jaroslav Kysela Date: Mon, 29 Aug 2016 11:46:22 +0200 Subject: [PATCH] filebundle: handle error code from stat() call --- src/filebundle.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/src/filebundle.c b/src/filebundle.c index 3d13a1f7c..4ebd9f3ea 100644 --- a/src/filebundle.c +++ b/src/filebundle.c @@ -328,12 +328,15 @@ fb_file *fb_open2 FILE *fp = tvh_fopen(path, "rb"); if (fp) { struct stat st; - stat(path, &st); - ret = calloc(1, sizeof(fb_file)); - ret->type = FB_DIRECT; - ret->size = st.st_size; - ret->gzip = 0; - ret->d.cur = fp; + if (!stat(path, &st)) { + ret = calloc(1, sizeof(fb_file)); + ret->type = FB_DIRECT; + ret->size = st.st_size; + ret->gzip = 0; + ret->d.cur = fp; + } else { + fclose(fp); + } } } -- 2.47.3