Audit of ao2_iterator_init() usage for v1.8.

Fixes numerous reference leaks and missing ao2_iterator_destroy() calls as
a result.

Review: https://reviewboard.asterisk.org/r/1697/
........

Merged revisions 352955 from http://svn.asterisk.org/svn/asterisk/branches/1.8
........

Merged revisions 352956 from http://svn.asterisk.org/svn/asterisk/branches/10


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@352957 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
Richard Mudgett
2012-01-27 18:47:16 +00:00
parent 5bfea5fdbf
commit 27b69e7d29
11 changed files with 89 additions and 55 deletions

View File

@@ -703,6 +703,7 @@ static u_char *ast_var_indications(struct variable *vp, oid *name, size_t *lengt
tz = ast_tone_zone_unref(tz);
long_ret++;
}
ao2_iterator_destroy(&i);
return (u_char *) &long_ret;
}
@@ -743,6 +744,7 @@ static u_char *ast_var_indications_table(struct variable *vp, oid *name, size_t
tz = ast_tone_zone_unref(tz);
i--;
}
ao2_iterator_destroy(&iter);
if (tz == NULL) {
return NULL;
@@ -750,24 +752,27 @@ static u_char *ast_var_indications_table(struct variable *vp, oid *name, size_t
switch (vp->magic) {
case ASTINDINDEX:
ast_tone_zone_unref(tz);
long_ret = name[*length - 1];
return (u_char *)&long_ret;
case ASTINDCOUNTRY:
ast_copy_string(ret_buf, tz->country, sizeof(ret_buf));
tz = ast_tone_zone_unref(tz);
ast_tone_zone_unref(tz);
*var_len = strlen(ret_buf);
return (u_char *) ret_buf;
case ASTINDALIAS:
/* No longer exists */
ast_tone_zone_unref(tz);
return NULL;
case ASTINDDESCRIPTION:
ast_tone_zone_lock(tz);
ast_copy_string(ret_buf, tz->description, sizeof(ret_buf));
ast_tone_zone_unlock(tz);
tz = ast_tone_zone_unref(tz);
ast_tone_zone_unref(tz);
*var_len = strlen(ret_buf);
return (u_char *) ret_buf;
default:
ast_tone_zone_unref(tz);
break;
}
return NULL;