]> git.ipfire.org Git - thirdparty/tvheadend.git/commitdiff
filebundle: handle error code from stat() call
authorJaroslav Kysela <perex@perex.cz>
Mon, 29 Aug 2016 09:46:22 +0000 (11:46 +0200)
committerJaroslav Kysela <perex@perex.cz>
Mon, 29 Aug 2016 09:46:22 +0000 (11:46 +0200)
src/filebundle.c

index 3d13a1f7cf7cb09b94ad7a80b1ad887779b17f8d..4ebd9f3ea62ad74a53794dfb78351481462d7dea 100644 (file)
@@ -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);
+      }
     }
   }