summaryrefslogtreecommitdiff
path: root/funcs
diff options
context:
space:
mode:
authorTilghman Lesher <tilghman@meg.abyt.es>2011-02-02 20:06:33 +0000
committerTilghman Lesher <tilghman@meg.abyt.es>2011-02-02 20:06:33 +0000
commit274032620051cf36d7bca098a85b25ae4a239515 (patch)
tree7a7de9612bfc165b7a525012220865890be4430a /funcs
parent93bade5639321193ae16a0ca656c701f45e8fbb5 (diff)
Merged revisions 305844 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.8 ........ r305844 | tilghman | 2011-02-02 14:05:43 -0600 (Wed, 02 Feb 2011) | 5 lines Eliminate a file descriptor leak when using the FILE() dialplan function. (closes issue #18731) Reported by: marioabajo ........ git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@305845 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'funcs')
-rw-r--r--funcs/func_env.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/funcs/func_env.c b/funcs/func_env.c
index 736095290..aa0abb4b3 100644
--- a/funcs/func_env.c
+++ b/funcs/func_env.c
@@ -499,6 +499,7 @@ static int file_read(struct ast_channel *chan, const char *cmd, char *data, stru
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 @@ static int file_read(struct ast_channel *chan, const char *cmd, char *data, stru
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 @@ static int file_read(struct ast_channel *chan, const char *cmd, char *data, stru
ast_str_append_substr(buf, len, fbuf, toappend);
}
+ fclose(ff);
return 0;
}
@@ -701,6 +704,7 @@ static int file_read(struct ast_channel *chan, const char *cmd, char *data, stru
}
}
+ fclose(ff);
return 0;
}
@@ -772,6 +776,8 @@ static int file_write(struct ast_channel *chan, const char *cmd, char *data, con
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);
}