summaryrefslogtreecommitdiff
path: root/main/media_index.c
diff options
context:
space:
mode:
authorRichard Mudgett <rmudgett@digium.com>2013-09-21 01:46:56 +0000
committerRichard Mudgett <rmudgett@digium.com>2013-09-21 01:46:56 +0000
commit46da169b6dcb36bd35177d69f492aa0ae750070e (patch)
treed1fff66c5c07eb0b17f25eb89951ad451edf08ff /main/media_index.c
parentdbec6e92d1a19e8537ab5bf7545e287ca5339df1 (diff)
media_index: Fix process_description_file() memory leak of file_id_persist.
........ Merged revisions 399596 from http://svn.asterisk.org/svn/asterisk/branches/12 git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@399597 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'main/media_index.c')
-rw-r--r--main/media_index.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/main/media_index.c b/main/media_index.c
index 943296ff4..605cee927 100644
--- a/main/media_index.c
+++ b/main/media_index.c
@@ -439,6 +439,7 @@ static int process_description_file(struct ast_media_index *index,
/* if there's text in cumulative_description, archive it and start anew */
if (file_id_persist && !ast_strlen_zero(ast_str_buffer(cumulative_description))) {
RAII_VAR(struct media_variant *, variant, NULL, ao2_cleanup);
+
variant = find_variant(index, file_id_persist, variant_str);
if (!variant) {
variant = alloc_variant(index, file_id_persist, variant_str);
@@ -451,11 +452,10 @@ static int process_description_file(struct ast_media_index *index,
ast_string_field_set(variant, description, ast_str_buffer(cumulative_description));
ast_str_reset(cumulative_description);
- ast_free(file_id_persist);
- file_id_persist = NULL;
}
- file_id_persist = strdup(file_identifier);
+ ast_free(file_id_persist);
+ file_id_persist = ast_strdup(file_identifier);
description = ast_skip_blanks(description);
ast_str_set(&cumulative_description, 0, "%s", description);
}
@@ -464,6 +464,7 @@ static int process_description_file(struct ast_media_index *index,
/* handle the last one */
if (file_id_persist && !ast_strlen_zero(ast_str_buffer(cumulative_description))) {
RAII_VAR(struct media_variant *, variant, NULL, ao2_cleanup);
+
variant = find_variant(index, file_id_persist, variant_str);
if (!variant) {
variant = alloc_variant(index, file_id_persist, variant_str);
@@ -471,12 +472,12 @@ static int process_description_file(struct ast_media_index *index,
if (variant) {
ast_string_field_set(variant, description, ast_str_buffer(cumulative_description));
- ast_free(file_id_persist);
} else {
res = -1;
}
}
+ ast_free(file_id_persist);
fclose(f);
return res;
}