]> git.ipfire.org Git - thirdparty/asterisk.git/commitdiff
don't try to call fclose() if fopen() failed
authorKevin P. Fleming <kpfleming@digium.com>
Wed, 15 Nov 2006 20:50:06 +0000 (20:50 +0000)
committerKevin P. Fleming <kpfleming@digium.com>
Wed, 15 Nov 2006 20:50:06 +0000 (20:50 +0000)
git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.4@47701 65c4cc65-6c06-0410-ace0-fbb531ad65f3

main/file.c

index dc664e08215aa97920947c5eed3a7b8f361cac72..6c78632626ab068275ccbbfb3888523c528389c8 100644 (file)
@@ -827,12 +827,13 @@ struct ast_filestream *ast_readfile(const char *filename, const char *type, cons
                errno = 0;
                bfile = fopen(fn, "r");
                if (!bfile || (fs = get_filestream(f, bfile)) == NULL ||
-                       open_wrapper(fs) ) {
+                   open_wrapper(fs) ) {
                        ast_log(LOG_WARNING, "Unable to open %s\n", fn);
-                       fclose(bfile);
-                       free(fn);
                        if (fs)
                                free(fs);
+                       if (bfile)
+                               fclose(bfile);
+                       free(fn);
                        continue;
                }
                /* found it */