[asterisk-commits] mjordan: branch 1.8 r366880 - in /branches/1.8: apps/ channels/ channels/sip/...
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Fri May 18 08:58:47 CDT 2012
Author: mjordan
Date: Fri May 18 08:58:23 2012
New Revision: 366880
URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=366880
Log:
Fix a variety of memory leaks
This patch addresses a number of memory leaks in a variety of modules that were
found by a static analysis tool. A brief summary of the changes:
* app_minivm: free ast_str objects on off nominal paths
* app_page: free the ast_dial object if the requested channel technology
cannot be appended to the dialing structure
* app_queue: if a penalty rule failed to match any existing rule list
names, the created rule would not be inserted and its memory
would be leaked
* app_read: dispose of the created silence detector in the presence of
off nominal circumstances
* app_voicemail: dispose of an allocated unique ID field for MWI event
un-subscribe requests in off nominal paths; dispose of
configuration objects when using the secret.conf option
* chan_dahdi: dispose of the allocated frame produced by ast_dsp_process
* chan_iax2: properly unref peer in CLI command "iax2 unregister"
* chan_sip: dispose of the allocated frame produced by sip_rtp_read's
call of ast_dsp_process; free memory in parse unit tests
* func_dialgroup: properly deref ao2 object grhead in nominal path of
dialgroup_read
* func_odbc: free resultset in off nominal paths of odbc_read
* cli: free match_list in off nominal paths of CLI match completion
* config: free comment_buffer/list_buffer when configuration file load
is unchanged; free the same buffers any time they were
created and config files were processed
* data: free XML nodes in various places
* enum: free context buffer in off nominal paths
* features: free ast_call_feature in off nominal paths of applicationmap
config processing
* netsock2: users of ast_sockaddr_resolve pass in an ast_sockaddr struct
that is allocated by the method. Failures in
ast_sockaddr_resolve could result in the users of the method
not knowing whether or not the buffer was allocated. The
method will now not allocate the ast_sockaddr struct if it
will return failure.
* pbx: cleanup hash table traversals in off nominal paths; free
ignore pattern buffer if it already exists for the specified
context
* xmldoc: cleanup various nodes when we no longer need them
* main/editline: various cleanup of pointers not being freed before being
assigned to other memory, cleanup along off nominal paths
* menuselect/mxml: cleanup of value buffer for an attribute when that attribute
did not specify a value
* res_calendar*: responses are allocated via the various *_request method
returns and should not be allocated in the various
write_event methods; ensure attendee buffer is freed if no
data exists in the parsed node; ensure that calendar objects
are de-ref'd appropriately
* res_jabber: free buffer in off nominal path
* res_musiconhold: close the DIR* object in off nominal paths
* res_rtp_asterisk: if we run out of ports, close the rtp socket object and free
the rtp object
* res_srtp: if we fail to create the session in libsrtp, destroy the
temporary ast_srtp object
(issue ASTERISK-19665)
Reported by: Matt Jordan
Review: https://reviewboard.asterisk.org/r/1922
Modified:
branches/1.8/apps/app_minivm.c
branches/1.8/apps/app_page.c
branches/1.8/apps/app_queue.c
branches/1.8/apps/app_record.c
branches/1.8/apps/app_voicemail.c
branches/1.8/channels/chan_dahdi.c
branches/1.8/channels/chan_iax2.c
branches/1.8/channels/chan_sip.c
branches/1.8/channels/sip/config_parser.c
branches/1.8/funcs/func_dialgroup.c
branches/1.8/funcs/func_odbc.c
branches/1.8/main/cli.c
branches/1.8/main/config.c
branches/1.8/main/data.c
branches/1.8/main/editline/readline.c
branches/1.8/main/editline/term.c
branches/1.8/main/editline/tokenizer.c
branches/1.8/main/enum.c
branches/1.8/main/features.c
branches/1.8/main/netsock2.c
branches/1.8/main/pbx.c
branches/1.8/main/xmldoc.c
branches/1.8/res/res_calendar.c
branches/1.8/res/res_calendar_caldav.c
branches/1.8/res/res_calendar_exchange.c
branches/1.8/res/res_calendar_icalendar.c
branches/1.8/res/res_jabber.c
branches/1.8/res/res_musiconhold.c
branches/1.8/res/res_rtp_asterisk.c
branches/1.8/res/res_srtp.c
Modified: branches/1.8/apps/app_minivm.c
URL: http://svnview.digium.com/svn/asterisk/branches/1.8/apps/app_minivm.c?view=diff&rev=366880&r1=366879&r2=366880
==============================================================================
--- branches/1.8/apps/app_minivm.c (original)
+++ branches/1.8/apps/app_minivm.c Fri May 18 08:58:23 2012
@@ -1255,6 +1255,8 @@
if (ast_strlen_zero(email)) {
ast_log(LOG_WARNING, "No address to send message to.\n");
+ ast_free(str1);
+ ast_free(str2);
return -1;
}
@@ -1309,11 +1311,15 @@
}
if (!p) {
ast_log(LOG_WARNING, "Unable to open temporary file '%s'\n", tmp);
+ ast_free(str1);
+ ast_free(str2);
return -1;
}
/* Allocate channel used for chanvar substitution */
ast = ast_dummy_channel_alloc();
if (!ast) {
+ ast_free(str1);
+ ast_free(str2);
return -1;
}
Modified: branches/1.8/apps/app_page.c
URL: http://svnview.digium.com/svn/asterisk/branches/1.8/apps/app_page.c?view=diff&rev=366880&r1=366879&r2=366880
==============================================================================
--- branches/1.8/apps/app_page.c (original)
+++ branches/1.8/apps/app_page.c Fri May 18 08:58:23 2012
@@ -248,6 +248,7 @@
/* Append technology and resource */
if (ast_dial_append(dial, tech, resource) == -1) {
ast_log(LOG_ERROR, "Failed to add %s to outbound dial\n", tech);
+ ast_dial_destroy(dial);
continue;
}
Modified: branches/1.8/apps/app_queue.c
URL: http://svnview.digium.com/svn/asterisk/branches/1.8/apps/app_queue.c?view=diff&rev=366880&r1=366879&r2=366880
==============================================================================
--- branches/1.8/apps/app_queue.c (original)
+++ branches/1.8/apps/app_queue.c Fri May 18 08:58:23 2012
@@ -1825,9 +1825,17 @@
if (!inserted) {
AST_LIST_INSERT_TAIL(&rl_iter->rules, rule, list);
- }
- }
-
+ inserted = 1;
+ }
+
+ break;
+ }
+
+ if (!inserted) {
+ ast_log(LOG_WARNING, "Unknown rule list name %s; ignoring.\n", list_name);
+ ast_free(rule);
+ return -1;
+ }
return 0;
}
@@ -4233,6 +4241,7 @@
ast_channel_lock(qe->chan);
if (!(ds = ast_datastore_alloc(&queue_transfer_info, NULL))) {
ast_channel_unlock(qe->chan);
+ ast_free(qtds);
ast_log(LOG_WARNING, "Unable to create transfer datastore. queue_log will not show attended transfer\n");
return NULL;
}
Modified: branches/1.8/apps/app_record.c
URL: http://svnview.digium.com/svn/asterisk/branches/1.8/apps/app_record.c?view=diff&rev=366880&r1=366879&r2=366880
==============================================================================
--- branches/1.8/apps/app_record.c (original)
+++ branches/1.8/apps/app_record.c Fri May 18 08:58:23 2012
@@ -414,12 +414,14 @@
out:
if ((silence > 0) && rfmt) {
res = ast_set_read_format(chan, rfmt);
- if (res)
+ if (res) {
ast_log(LOG_WARNING, "Unable to restore read format on '%s'\n", chan->name);
- if (sildet)
- ast_dsp_free(sildet);
- }
-
+ }
+ }
+
+ if (sildet) {
+ ast_dsp_free(sildet);
+ }
return res;
}
Modified: branches/1.8/apps/app_voicemail.c
URL: http://svnview.digium.com/svn/asterisk/branches/1.8/apps/app_voicemail.c?view=diff&rev=366880&r1=366879&r2=366880
==============================================================================
--- branches/1.8/apps/app_voicemail.c (original)
+++ branches/1.8/apps/app_voicemail.c Fri May 18 08:58:23 2012
@@ -11527,16 +11527,22 @@
static void mwi_unsub_event_cb(const struct ast_event *event, void *userdata)
{
uint32_t u, *uniqueid = ast_calloc(1, sizeof(*uniqueid));
- if (ast_event_get_type(event) != AST_EVENT_UNSUB)
- return;
-
- if (ast_event_get_ie_uint(event, AST_EVENT_IE_EVENTTYPE) != AST_EVENT_MWI)
- return;
if (!uniqueid) {
ast_log(LOG_ERROR, "Unable to allocate memory for uniqueid\n");
return;
}
+
+ if (ast_event_get_type(event) != AST_EVENT_UNSUB) {
+ ast_free(uniqueid);
+ return;
+ }
+
+ if (ast_event_get_ie_uint(event, AST_EVENT_IE_EVENTTYPE) != AST_EVENT_MWI) {
+ ast_free(uniqueid);
+ return;
+ }
+
u = ast_event_get_ie_uint(event, AST_EVENT_IE_UNIQUEID);
*uniqueid = u;
if (ast_taskprocessor_push(mwi_subscription_tps, handle_unsubscribe, uniqueid) < 0) {
@@ -12520,8 +12526,10 @@
const char *val = ast_variable_retrieve(pwconf, "general", "password");
if (val) {
ast_copy_string(password, val, passwordlen);
- return;
- }
+ ast_config_destroy(pwconf);
+ return;
+ }
+ ast_config_destroy(pwconf);
}
ast_log(LOG_NOTICE, "Failed reading voicemail password from %s, using secret from config file\n", secretfn);
}
@@ -12530,26 +12538,33 @@
struct ast_config *conf;
struct ast_category *cat;
struct ast_variable *var;
-
- if (!(conf=ast_config_new())) {
+ int res = -1;
+
+ if (!(conf = ast_config_new())) {
ast_log(LOG_ERROR, "Error creating new config structure\n");
- return -1;
- }
- if (!(cat=ast_category_new("general","",1))) {
+ return res;
+ }
+ if (!(cat = ast_category_new("general", "", 1))) {
ast_log(LOG_ERROR, "Error creating new category structure\n");
- return -1;
- }
- if (!(var=ast_variable_new("password",password,""))) {
+ ast_config_destroy(conf);
+ return res;
+ }
+ if (!(var = ast_variable_new("password", password, ""))) {
ast_log(LOG_ERROR, "Error creating new variable structure\n");
- return -1;
- }
- ast_category_append(conf,cat);
- ast_variable_append(cat,var);
- if (ast_config_text_file_save(secretfn, conf, "app_voicemail")) {
+ ast_config_destroy(conf);
+ ast_category_destroy(cat);
+ return res;
+ }
+ ast_category_append(conf, cat);
+ ast_variable_append(cat, var);
+ if (!ast_config_text_file_save(secretfn, conf, "app_voicemail")) {
+ res = 0;
+ } else {
ast_log(LOG_ERROR, "Error writing voicemail password to %s\n", secretfn);
- return -1;
- }
- return 0;
+ }
+
+ ast_config_destroy(conf);
+ return res;
}
static int vmsayname_exec(struct ast_channel *chan, const char *data)
Modified: branches/1.8/channels/chan_dahdi.c
URL: http://svnview.digium.com/svn/asterisk/branches/1.8/channels/chan_dahdi.c?view=diff&rev=366880&r1=366879&r2=366880
==============================================================================
--- branches/1.8/channels/chan_dahdi.c (original)
+++ branches/1.8/channels/chan_dahdi.c Fri May 18 08:58:23 2012
@@ -9221,6 +9221,7 @@
if ((ast->_state == AST_STATE_UP) && !p->outgoing) {
/* Treat this as a "hangup" instead of a "busy" on the assumption that
a busy */
+ ast_frfree(f);
f = NULL;
}
} else if (f->frametype == AST_FRAME_DTMF_BEGIN
@@ -9246,7 +9247,8 @@
if (ast_tvdiff_ms(ast_tvnow(), p->waitingfordt) >= p->waitfordialtone ) {
p->waitingfordt.tv_sec = 0;
ast_log(LOG_WARNING, "Never saw dialtone on channel %d\n", p->channel);
- f=NULL;
+ ast_frfree(f);
+ f = NULL;
} else if (f->frametype == AST_FRAME_VOICE) {
f->frametype = AST_FRAME_NULL;
f->subclass.integer = 0;
@@ -9261,6 +9263,7 @@
ast_log(LOG_WARNING, "Unable to initiate dialing on trunk channel %d\n", p->channel);
p->dop.dialstr[0] = '\0';
ast_mutex_unlock(&p->lock);
+ ast_frfree(f);
return NULL;
} else {
ast_log(LOG_DEBUG, "Sent deferred digit string: %s\n", p->dop.dialstr);
Modified: branches/1.8/channels/chan_iax2.c
URL: http://svnview.digium.com/svn/asterisk/branches/1.8/channels/chan_iax2.c?view=diff&rev=366880&r1=366879&r2=366880
==============================================================================
--- branches/1.8/channels/chan_iax2.c (original)
+++ branches/1.8/channels/chan_iax2.c Fri May 18 08:58:23 2012
@@ -6883,6 +6883,7 @@
} else {
ast_cli(a->fd, "Peer %s not registered\n", a->argv[2]);
}
+ peer_unref(p);
} else {
ast_cli(a->fd, "Peer unknown: %s. Not unregistered\n", a->argv[2]);
}
@@ -9839,6 +9840,7 @@
}
varlist = ast_calloc(1, sizeof(*varlist));
if (!varlist) {
+ ast_datastore_free(variablestore);
ast_log(LOG_ERROR, "Unable to assign new variable '%s'\n", data);
return -1;
}
Modified: branches/1.8/channels/chan_sip.c
URL: http://svnview.digium.com/svn/asterisk/branches/1.8/channels/chan_sip.c?view=diff&rev=366880&r1=366879&r2=366880
==============================================================================
--- branches/1.8/channels/chan_sip.c (original)
+++ branches/1.8/channels/chan_sip.c Fri May 18 08:58:23 2012
@@ -7463,7 +7463,7 @@
}
}
}
-
+
return f;
}
@@ -7498,6 +7498,7 @@
if (ast_async_goto(ast, target_context, "fax", 1)) {
ast_log(LOG_NOTICE, "Failed to async goto '%s' into fax of '%s'\n", ast->name, target_context);
}
+ ast_frfree(fr);
fr = &ast_null_frame;
} else {
ast_channel_lock(ast);
@@ -7509,6 +7510,7 @@
/* Only allow audio through if they sent progress with SDP, or if the channel is actually answered */
if (fr && fr->frametype == AST_FRAME_VOICE && p->invitestate != INV_EARLY_MEDIA && ast->_state != AST_STATE_UP) {
+ ast_frfree(fr);
fr = &ast_null_frame;
}
Modified: branches/1.8/channels/sip/config_parser.c
URL: http://svnview.digium.com/svn/asterisk/branches/1.8/channels/sip/config_parser.c?view=diff&rev=366880&r1=366879&r2=366880
==============================================================================
--- branches/1.8/channels/sip/config_parser.c (original)
+++ branches/1.8/channels/sip/config_parser.c Fri May 18 08:58:23 2012
@@ -556,6 +556,8 @@
ast_test_status_update(test, "Test 12, add domain port failed.\n");
res = AST_TEST_FAIL;
}
+ ast_string_field_free_memory(reg);
+ ast_free(reg);
/* ---Test reg13, domain port without secret --- */
if (!(reg = ast_calloc_with_stringfields(1, struct sip_registry, 256))) {
@@ -582,7 +584,9 @@
ast_test_status_update(test, "Test 13, domain port without secret failed.\n");
res = AST_TEST_FAIL;
-}
+ }
+ ast_string_field_free_memory(reg);
+ ast_free(reg);
/* ---Test reg 9, missing domain, expected to fail --- */
if (!(reg = ast_calloc_with_stringfields(1, struct sip_registry, 256))) {
Modified: branches/1.8/funcs/func_dialgroup.c
URL: http://svnview.digium.com/svn/asterisk/branches/1.8/funcs/func_dialgroup.c?view=diff&rev=366880&r1=366879&r2=366880
==============================================================================
--- branches/1.8/funcs/func_dialgroup.c (original)
+++ branches/1.8/funcs/func_dialgroup.c Fri May 18 08:58:23 2012
@@ -165,6 +165,7 @@
ao2_ref(entry, -1);
}
ao2_iterator_destroy(&i);
+ ao2_ref(grhead, -1);
return res;
}
Modified: branches/1.8/funcs/func_odbc.c
URL: http://svnview.digium.com/svn/asterisk/branches/1.8/funcs/func_odbc.c?view=diff&rev=366880&r1=366879&r2=366880
==============================================================================
--- branches/1.8/funcs/func_odbc.c (original)
+++ branches/1.8/funcs/func_odbc.c Fri May 18 08:58:23 2012
@@ -539,6 +539,7 @@
pbx_builtin_setvar_helper(chan, "ODBCROWS", rowcount);
ast_autoservice_stop(chan);
}
+ ast_free(resultset);
return -1;
}
@@ -553,6 +554,7 @@
pbx_builtin_setvar_helper(chan, "ODBCROWS", rowcount);
ast_autoservice_stop(chan);
}
+ ast_free(resultset);
return -1;
}
@@ -578,6 +580,7 @@
pbx_builtin_setvar_helper(chan, "ODBCSTATUS", status);
ast_autoservice_stop(chan);
}
+ ast_free(resultset);
return res1;
}
Modified: branches/1.8/main/cli.c
URL: http://svnview.digium.com/svn/asterisk/branches/1.8/main/cli.c?view=diff&rev=366880&r1=366879&r2=366880
==============================================================================
--- branches/1.8/main/cli.c (original)
+++ branches/1.8/main/cli.c Fri May 18 08:58:23 2012
@@ -2340,9 +2340,11 @@
max_equal = i;
}
- if (!(retstr = ast_malloc(max_equal + 1)))
- return NULL;
-
+ if (!(retstr = ast_malloc(max_equal + 1))) {
+ ast_free(match_list);
+ return NULL;
+ }
+
ast_copy_string(retstr, match_list[1], max_equal + 1);
match_list[0] = retstr;
Modified: branches/1.8/main/config.c
URL: http://svnview.digium.com/svn/asterisk/branches/1.8/main/config.c?view=diff&rev=366880&r1=366879&r2=366880
==============================================================================
--- branches/1.8/main/config.c (original)
+++ branches/1.8/main/config.c Fri May 18 08:58:23 2012
@@ -1487,6 +1487,8 @@
if (unchanged) {
AST_LIST_UNLOCK(&cfmtime_head);
+ ast_free(comment_buffer);
+ ast_free(lline_buffer);
return CONFIG_STATUS_FILEUNCHANGED;
}
}
@@ -1641,13 +1643,13 @@
}
#endif
- if (cfg && cfg != CONFIG_STATUS_FILEUNCHANGED && cfg != CONFIG_STATUS_FILEINVALID && cfg->include_level == 1 && ast_test_flag(&flags, CONFIG_FLAG_WITHCOMMENTS)) {
+ if (ast_test_flag(&flags, CONFIG_FLAG_WITHCOMMENTS)) {
ast_free(comment_buffer);
ast_free(lline_buffer);
comment_buffer = NULL;
lline_buffer = NULL;
}
-
+
if (count == 0)
return NULL;
Modified: branches/1.8/main/data.c
URL: http://svnview.digium.com/svn/asterisk/branches/1.8/main/data.c?view=diff&rev=366880&r1=366879&r2=366880
==============================================================================
--- branches/1.8/main/data.c (original)
+++ branches/1.8/main/data.c Fri May 18 08:58:23 2012
@@ -1042,6 +1042,7 @@
cmp_type = child->cmp_type;
if (sscanf(child->value, "%p", &node_ptr) <= 0) {
+ ao2_ref(child, -1);
return 1;
}
@@ -2186,6 +2187,7 @@
doc = ast_xml_new();
if (!doc) {
+ ast_data_free(res);
return NULL;
}
Modified: branches/1.8/main/editline/readline.c
URL: http://svnview.digium.com/svn/asterisk/branches/1.8/main/editline/readline.c?view=diff&rev=366880&r1=366879&r2=366880
==============================================================================
--- branches/1.8/main/editline/readline.c (original)
+++ branches/1.8/main/editline/readline.c Fri May 18 08:58:23 2012
@@ -549,6 +549,7 @@
from = strdup(search);
else {
from = NULL;
+ free(line);
return (-1);
}
}
@@ -609,8 +610,13 @@
end = max - ((end < -1) ? 1 : 0);
/* check boundaries ... */
- if (start > max || end > max || start > end)
+ if (start > max || end > max || start > end) {
+ for (i = 0; i <= max; i++) {
+ free(arr[i]);
+ }
+ free(arr), arr = (char **) NULL;
return (-1);
+ }
for (i = 0; i <= max; i++) {
char *temp;
Modified: branches/1.8/main/editline/term.c
URL: http://svnview.digium.com/svn/asterisk/branches/1.8/main/editline/term.c?view=diff&rev=366880&r1=366879&r2=366880
==============================================================================
--- branches/1.8/main/editline/term.c (original)
+++ branches/1.8/main/editline/term.c Fri May 18 08:58:23 2012
@@ -472,7 +472,7 @@
private int
term_alloc_display(EditLine *el)
{
- int i;
+ int i, j;
char **b;
coord_t *c = &el->el_term.t_size;
@@ -481,8 +481,13 @@
return (-1);
for (i = 0; i < c->v; i++) {
b[i] = (char *) el_malloc((size_t) (sizeof(char) * (c->h + 1)));
- if (b[i] == NULL)
+ if (b[i] == NULL) {
+ for (j = 0; j < i; j++) {
+ el_free(b[j]);
+ }
+ el_free(b);
return (-1);
+ }
}
b[c->v] = NULL;
el->el_display = b;
@@ -492,8 +497,13 @@
return (-1);
for (i = 0; i < c->v; i++) {
b[i] = (char *) el_malloc((size_t) (sizeof(char) * (c->h + 1)));
- if (b[i] == NULL)
+ if (b[i] == NULL) {
+ for (j = 0; j < i; j++) {
+ el_free(b[j]);
+ }
+ el_free(b);
return (-1);
+ }
}
b[c->v] = NULL;
el->el_vdisplay = b;
Modified: branches/1.8/main/editline/tokenizer.c
URL: http://svnview.digium.com/svn/asterisk/branches/1.8/main/editline/tokenizer.c?view=diff&rev=366880&r1=366879&r2=366880
==============================================================================
--- branches/1.8/main/editline/tokenizer.c (original)
+++ branches/1.8/main/editline/tokenizer.c Fri May 18 08:58:23 2012
@@ -113,12 +113,17 @@
tok->argc = 0;
tok->amax = AINCR;
tok->argv = (char **) tok_malloc(sizeof(char *) * tok->amax);
- if (tok->argv == NULL)
+ if (tok->argv == NULL) {
+ tok_free(tok);
return (NULL);
+ }
tok->argv[0] = NULL;
tok->wspace = (char *) tok_malloc(WINCR);
- if (tok->wspace == NULL)
+ if (tok->wspace == NULL) {
+ tok_free(tok->argv);
+ tok_free(tok);
return (NULL);
+ }
tok->wmax = tok->wspace + WINCR;
tok->wstart = tok->wspace;
tok->wptr = tok->wspace;
Modified: branches/1.8/main/enum.c
URL: http://svnview.digium.com/svn/asterisk/branches/1.8/main/enum.c?view=diff&rev=366880&r1=366879&r2=366880
==============================================================================
--- branches/1.8/main/enum.c (original)
+++ branches/1.8/main/enum.c Fri May 18 08:58:23 2012
@@ -790,6 +790,7 @@
if (sdl > strlen(number)) { /* Number too short for this sdl? */
ast_log(LOG_WARNING, "I-ENUM: subdomain location %d behind number %s\n", sdl, number);
+ ast_free(context);
return 0;
}
ast_copy_string(left, number + sdl, sizeof(left));
@@ -802,6 +803,7 @@
/* check the space we need for middle */
if ((sdl * 2 + strlen(middle) + 2) > sizeof(middle)) {
ast_log(LOG_WARNING, "ast_get_enum: not enough space for I-ENUM rewrite.\n");
+ ast_free(context);
return -1;
}
@@ -819,6 +821,7 @@
if (strlen(left) * 2 + 2 > sizeof(domain)) {
ast_log(LOG_WARNING, "string to long in ast_get_enum\n");
+ ast_free(context);
return -1;
}
Modified: branches/1.8/main/features.c
URL: http://svnview.digium.com/svn/asterisk/branches/1.8/main/features.c?view=diff&rev=366880&r1=366879&r2=366880
==============================================================================
--- branches/1.8/main/features.c (original)
+++ branches/1.8/main/features.c Fri May 18 08:58:23 2012
@@ -5725,6 +5725,7 @@
} else {
ast_log(LOG_NOTICE, "Invalid 'ActivateOn' specification for feature '%s',"
" must be 'self', or 'peer'\n", var->name);
+ ast_free(feature);
return;
}
@@ -5739,6 +5740,7 @@
} else {
ast_log(LOG_NOTICE, "Invalid 'ActivatedBy' specification for feature '%s',"
" must be 'caller', or 'callee', or 'both'\n", var->name);
+ ast_free(feature);
return;
}
Modified: branches/1.8/main/netsock2.c
URL: http://svnview.digium.com/svn/asterisk/branches/1.8/main/netsock2.c?view=diff&rev=366880&r1=366879&r2=366880
==============================================================================
--- branches/1.8/main/netsock2.c (original)
+++ branches/1.8/main/netsock2.c Fri May 18 08:58:23 2012
@@ -270,6 +270,10 @@
res_cnt++;
}
+ if (res_cnt == 0) {
+ goto cleanup;
+ }
+
if ((*addrs = ast_malloc(res_cnt * sizeof(struct ast_sockaddr))) == NULL) {
res_cnt = 0;
goto cleanup;
Modified: branches/1.8/main/pbx.c
URL: http://svnview.digium.com/svn/asterisk/branches/1.8/main/pbx.c?view=diff&rev=366880&r1=366879&r2=366880
==============================================================================
--- branches/1.8/main/pbx.c (original)
+++ branches/1.8/main/pbx.c Fri May 18 08:58:23 2012
@@ -7334,6 +7334,8 @@
if (!new) {
ast_log(LOG_ERROR,"Could not allocate a new context for %s in merge_and_delete! Danger!\n", context->name);
+ ast_hashtab_end_traversal(prio_iter);
+ ast_hashtab_end_traversal(exten_iter);
return; /* no sense continuing. */
}
/* we will not replace existing entries in the new context with stuff from the old context.
@@ -8059,6 +8061,7 @@
if (!strcasecmp(ignorepatc->pattern, value)) {
/* Already there */
ast_unlock_context(con);
+ ast_free(ignorepat);
errno = EEXIST;
return -1;
}
Modified: branches/1.8/main/xmldoc.c
URL: http://svnview.digium.com/svn/asterisk/branches/1.8/main/xmldoc.c?view=diff&rev=366880&r1=366879&r2=366880
==============================================================================
--- branches/1.8/main/xmldoc.c (original)
+++ branches/1.8/main/xmldoc.c Fri May 18 08:58:23 2012
@@ -1666,6 +1666,7 @@
ast_str_append(buffer, 0, "\n");
ast_xml_free_attr(optname);
ast_xml_free_attr(hasparams);
+ ast_free(optionsyntax);
}
}
@@ -1740,12 +1741,14 @@
char *retstr = NULL;
if (ast_strlen_zero(type) || ast_strlen_zero(name)) {
+ ast_free(ret);
return NULL;
}
node = xmldoc_get_node(type, name, module, documentation_language);
if (!node || !ast_xml_node_get_children(node)) {
+ ast_free(ret);
return NULL;
}
@@ -1758,6 +1761,7 @@
if (!node || !ast_xml_node_get_children(node)) {
/* We couldn't find the syntax node. */
+ ast_free(ret);
return NULL;
}
Modified: branches/1.8/res/res_calendar.c
URL: http://svnview.digium.com/svn/asterisk/branches/1.8/res/res_calendar.c?view=diff&rev=366880&r1=366879&r2=366880
==============================================================================
--- branches/1.8/res/res_calendar.c (original)
+++ branches/1.8/res/res_calendar.c Fri May 18 08:58:23 2012
@@ -358,6 +358,7 @@
static enum ast_device_state calendarstate(const char *data)
{
+ enum ast_device_state state;
struct ast_calendar *cal;
if (ast_strlen_zero(data) || (!(cal = find_calendar(data)))) {
@@ -365,10 +366,13 @@
}
if (cal->tech->is_busy) {
- return cal->tech->is_busy(cal) ? AST_DEVICE_INUSE : AST_DEVICE_NOT_INUSE;
- }
-
- return calendar_is_busy(cal) ? AST_DEVICE_INUSE : AST_DEVICE_NOT_INUSE;
+ state = cal->tech->is_busy(cal) ? AST_DEVICE_INUSE : AST_DEVICE_NOT_INUSE;
+ } else {
+ state = calendar_is_busy(cal) ? AST_DEVICE_INUSE : AST_DEVICE_NOT_INUSE;
+ }
+
+ cal = unref_calendar(cal);
+ return state;
}
static struct ast_calendar *build_calendar(struct ast_config *cfg, const char *cat, const struct ast_calendar_tech *tech)
@@ -1007,6 +1011,7 @@
}
strcpy(buf, calendar_is_busy(cal) ? "1" : "0");
+ cal = unref_calendar(cal);
return 0;
}
@@ -1161,6 +1166,8 @@
ast_debug(10, "%s (%ld - %ld) overlapped with (%ld - %ld)\n", event->summary, (long) event->start, (long) event->end, (long) start, (long) end);
if (add_event_to_list(events, event, start, end) < 0) {
event = ast_calendar_unref_event(event);
+ cal = unref_calendar(cal);
+ ao2_ref(events, -1);
ao2_iterator_destroy(&i);
return -1;
}
@@ -1178,6 +1185,8 @@
if (!(eventlist_datastore = ast_datastore_alloc(&eventlist_datastore_info, buf))) {
ast_log(LOG_ERROR, "Could not allocate datastore!\n");
+ cal = unref_calendar(cal);
+ ao2_ref(events, -1);
return -1;
}
@@ -1188,6 +1197,7 @@
ast_channel_datastore_add(chan, eventlist_datastore);
ast_channel_unlock(chan);
+ cal = unref_calendar(cal);
return 0;
}
Modified: branches/1.8/res/res_calendar_caldav.c
URL: http://svnview.digium.com/svn/asterisk/branches/1.8/res/res_calendar_caldav.c?view=diff&rev=366880&r1=366879&r2=366880
==============================================================================
--- branches/1.8/res/res_calendar_caldav.c (original)
+++ branches/1.8/res/res_calendar_caldav.c Fri May 18 08:58:23 2012
@@ -181,9 +181,8 @@
return -1;
}
if (!(body = ast_str_create(512)) ||
- !(subdir = ast_str_create(32)) ||
- !(response = ast_str_create(512))) {
- ast_log(LOG_ERROR, "Could not allocate memory for request and response!\n");
+ !(subdir = ast_str_create(32))) {
+ ast_log(LOG_ERROR, "Could not allocate memory for request!\n");
goto write_cleanup;
}
@@ -406,10 +405,12 @@
return;
}
data = icalproperty_get_attendee(prop);
- if (!ast_strlen_zero(data)) {
- attendee->data = ast_strdup(data);;
- AST_LIST_INSERT_TAIL(&event->attendees, attendee, next);
- }
+ if (ast_strlen_zero(data)) {
+ ast_free(attendee);
+ continue;
+ }
+ attendee->data = ast_strdup(data);
+ AST_LIST_INSERT_TAIL(&event->attendees, attendee, next);
}
Modified: branches/1.8/res/res_calendar_exchange.c
URL: http://svnview.digium.com/svn/asterisk/branches/1.8/res/res_calendar_exchange.c?view=diff&rev=366880&r1=366879&r2=366880
==============================================================================
--- branches/1.8/res/res_calendar_exchange.c (original)
+++ branches/1.8/res/res_calendar_exchange.c Fri May 18 08:58:23 2012
@@ -433,9 +433,8 @@
return -1;
}
if (!(body = ast_str_create(512)) ||
- !(subdir = ast_str_create(32)) ||
- !(response = ast_str_create(512))) {
- ast_log(LOG_ERROR, "Could not allocate memory for request and response!\n");
+ !(subdir = ast_str_create(32))) {
+ ast_log(LOG_ERROR, "Could not allocate memory for request!\n");
goto write_cleanup;
}
Modified: branches/1.8/res/res_calendar_icalendar.c
URL: http://svnview.digium.com/svn/asterisk/branches/1.8/res/res_calendar_icalendar.c?view=diff&rev=366880&r1=366879&r2=366880
==============================================================================
--- branches/1.8/res/res_calendar_icalendar.c (original)
+++ branches/1.8/res/res_calendar_icalendar.c Fri May 18 08:58:23 2012
@@ -261,10 +261,12 @@
return;
}
data = icalproperty_get_attendee(prop);
- if (!ast_strlen_zero(data)) {
- attendee->data = ast_strdup(data);;
- AST_LIST_INSERT_TAIL(&event->attendees, attendee, next);
- }
+ if (ast_strlen_zero(data)) {
+ ast_free(attendee);
+ continue;
+ }
+ attendee->data = ast_strdup(data);;
+ AST_LIST_INSERT_TAIL(&event->attendees, attendee, next);
}
Modified: branches/1.8/res/res_jabber.c
URL: http://svnview.digium.com/svn/asterisk/branches/1.8/res/res_jabber.c?view=diff&rev=366880&r1=366879&r2=366880
==============================================================================
--- branches/1.8/res/res_jabber.c (original)
+++ branches/1.8/res/res_jabber.c Fri May 18 08:58:23 2012
@@ -2252,6 +2252,7 @@
/* insert will furtherly be added to message list */
insert->from = ast_strdup(pak->from->full);
if (!insert->from) {
+ ast_free(insert);
ast_log(LOG_ERROR, "Memory allocation failure\n");
return;
}
Modified: branches/1.8/res/res_musiconhold.c
URL: http://svnview.digium.com/svn/asterisk/branches/1.8/res/res_musiconhold.c?view=diff&rev=366880&r1=366879&r2=366880
==============================================================================
--- branches/1.8/res/res_musiconhold.c (original)
+++ branches/1.8/res/res_musiconhold.c Fri May 18 08:58:23 2012
@@ -1065,10 +1065,12 @@
class->total_files = 0;
if (!getcwd(path, sizeof(path))) {
ast_log(LOG_WARNING, "getcwd() failed: %s\n", strerror(errno));
+ closedir(files_DIR);
return -1;
}
if (chdir(dir_path) < 0) {
ast_log(LOG_WARNING, "chdir() failed: %s\n", strerror(errno));
+ closedir(files_DIR);
return -1;
}
while ((files_dirent = readdir(files_DIR))) {
Modified: branches/1.8/res/res_rtp_asterisk.c
URL: http://svnview.digium.com/svn/asterisk/branches/1.8/res/res_rtp_asterisk.c?view=diff&rev=366880&r1=366879&r2=366880
==============================================================================
--- branches/1.8/res/res_rtp_asterisk.c (original)
+++ branches/1.8/res/res_rtp_asterisk.c Fri May 18 08:58:23 2012
@@ -566,6 +566,8 @@
/* See if we ran out of ports or if the bind actually failed because of something other than the address being in use */
if (x == startplace || errno != EADDRINUSE) {
ast_log(LOG_ERROR, "Oh dear... we couldn't allocate a port for RTP instance '%p'\n", instance);
+ close(rtp->s);
+ ast_free(rtp);
return -1;
}
}
Modified: branches/1.8/res/res_srtp.c
URL: http://svnview.digium.com/svn/asterisk/branches/1.8/res/res_srtp.c?view=diff&rev=366880&r1=366879&r2=366880
==============================================================================
--- branches/1.8/res/res_srtp.c (original)
+++ branches/1.8/res/res_srtp.c Fri May 18 08:58:23 2012
@@ -433,12 +433,14 @@
if (!(temp = res_srtp_new())) {
return -1;
}
-
+ ast_module_ref(ast_module_info->self);
+
+ /* Any failures after this point can use ast_srtp_destroy to destroy the instance */
if (srtp_create(&temp->session, &policy->sp) != err_status_ok) {
- return -1;
- }
-
- ast_module_ref(ast_module_info->self);
+ ast_srtp_destroy(temp);
+ return -1;
+ }
+
temp->rtp = rtp;
*srtp = temp;
More information about the asterisk-commits
mailing list