[asterisk-commits] tilghman: branch 1.8 r305844 - /branches/1.8/funcs/func_env.c

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Wed Feb 2 14:05:47 CST 2011


Author: tilghman
Date: Wed Feb  2 14:05:43 2011
New Revision: 305844

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=305844
Log:
Eliminate a file descriptor leak when using the FILE() dialplan function.

(closes issue #18731)
Reported by: marioabajo

Modified:
    branches/1.8/funcs/func_env.c

Modified: branches/1.8/funcs/func_env.c
URL: http://svnview.digium.com/svn/asterisk/branches/1.8/funcs/func_env.c?view=diff&rev=305844&r1=305843&r2=305844
==============================================================================
--- branches/1.8/funcs/func_env.c (original)
+++ branches/1.8/funcs/func_env.c Wed Feb  2 14:05:43 2011
@@ -499,6 +499,7 @@
 
 		if (fseeko(ff, 0, SEEK_END) < 0) {
 			ast_log(LOG_ERROR, "Cannot seek to end of '%s': %s\n", args.filename, strerror(errno));
+			fclose(ff);
 			return -1;
 		}
 		flength = ftello(ff);
@@ -511,6 +512,7 @@
 			fseeko(ff, length, SEEK_END);
 			if ((length = ftello(ff)) - offset < 0) {
 				/* Eliminates all results */
+				fclose(ff);
 				return -1;
 			}
 		} else if (length == LLONG_MAX) {
@@ -537,6 +539,7 @@
 
 			ast_str_append_substr(buf, len, fbuf, toappend);
 		}
+		fclose(ff);
 		return 0;
 	}
 
@@ -701,6 +704,7 @@
 		}
 	}
 
+	fclose(ff);
 	return 0;
 }
 
@@ -772,6 +776,8 @@
 		if (offset < 0) {
 			if (fseeko(ff, offset, SEEK_END)) {
 				ast_log(LOG_ERROR, "Cannot seek to offset: %s\n", strerror(errno));
+				fclose(ff);
+				return -1;
 			}
 			offset = ftello(ff);
 		}




More information about the asterisk-commits mailing list