From: Jaroslav Kysela Date: Mon, 29 Aug 2016 09:46:22 +0000 (+0200) Subject: filebundle: handle error code from stat() call X-Git-Tag: v4.2.1~340 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=1c1ef10173fbcee3c78a82541a0c540bca8e1189;p=thirdparty%2Ftvheadend.git filebundle: handle error code from stat() call --- 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); + } } }