summaryrefslogtreecommitdiff
path: root/res
diff options
context:
space:
mode:
Diffstat (limited to 'res')
-rw-r--r--res/res_calendar.c14
-rw-r--r--res/res_calendar_caldav.c13
-rw-r--r--res/res_calendar_exchange.c5
-rw-r--r--res/res_calendar_icalendar.c8
-rw-r--r--res/res_jabber.c1
-rw-r--r--res/res_rtp_asterisk.c2
-rw-r--r--res/res_srtp.c4
7 files changed, 32 insertions, 15 deletions
diff --git a/res/res_calendar.c b/res/res_calendar.c
index 5ddcaae07..8c349946b 100644
--- a/res/res_calendar.c
+++ b/res/res_calendar.c
@@ -374,6 +374,7 @@ static int calendar_is_busy(struct ast_calendar *cal)
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)))) {
@@ -381,10 +382,13 @@ static enum ast_device_state calendarstate(const char *data)
}
if (cal->tech->is_busy) {
- return cal->tech->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;
}
- return 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)
@@ -1060,6 +1064,7 @@ static int calendar_busy_exec(struct ast_channel *chan, const char *cmd, char *d
}
strcpy(buf, calendar_is_busy(cal) ? "1" : "0");
+ cal = unref_calendar(cal);
return 0;
}
@@ -1214,6 +1219,8 @@ static int calendar_query_exec(struct ast_channel *chan, const char *cmd, char *
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;
}
@@ -1231,6 +1238,8 @@ static int calendar_query_exec(struct ast_channel *chan, const char *cmd, char *
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;
}
@@ -1241,6 +1250,7 @@ static int calendar_query_exec(struct ast_channel *chan, const char *cmd, char *
ast_channel_datastore_add(chan, eventlist_datastore);
ast_channel_unlock(chan);
+ cal = unref_calendar(cal);
return 0;
}
diff --git a/res/res_calendar_caldav.c b/res/res_calendar_caldav.c
index 88b043290..b1dd628a8 100644
--- a/res/res_calendar_caldav.c
+++ b/res/res_calendar_caldav.c
@@ -188,9 +188,8 @@ static int caldav_write_event(struct ast_calendar_event *event)
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;
}
@@ -417,10 +416,12 @@ static void caldav_add_event(icalcomponent *comp, struct icaltime_span *span, vo
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);
}
diff --git a/res/res_calendar_exchange.c b/res/res_calendar_exchange.c
index 6c0982a63..e7beeafb2 100644
--- a/res/res_calendar_exchange.c
+++ b/res/res_calendar_exchange.c
@@ -433,9 +433,8 @@ static int exchangecal_write_event(struct ast_calendar_event *event)
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;
}
diff --git a/res/res_calendar_icalendar.c b/res/res_calendar_icalendar.c
index b177b4941..dc7b5f31c 100644
--- a/res/res_calendar_icalendar.c
+++ b/res/res_calendar_icalendar.c
@@ -261,10 +261,12 @@ static void icalendar_add_event(icalcomponent *comp, struct icaltime_span *span,
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);
}
diff --git a/res/res_jabber.c b/res/res_jabber.c
index a68864f22..384b12c43 100644
--- a/res/res_jabber.c
+++ b/res/res_jabber.c
@@ -2292,6 +2292,7 @@ static void aji_handle_message(struct aji_client *client, ikspak *pak)
/* 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;
}
diff --git a/res/res_rtp_asterisk.c b/res/res_rtp_asterisk.c
index 62a321147..32b762e8d 100644
--- a/res/res_rtp_asterisk.c
+++ b/res/res_rtp_asterisk.c
@@ -566,6 +566,8 @@ static int ast_rtp_new(struct ast_rtp_instance *instance,
/* 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;
}
}
diff --git a/res/res_srtp.c b/res/res_srtp.c
index 756c62e2f..f651c4067 100644
--- a/res/res_srtp.c
+++ b/res/res_srtp.c
@@ -433,12 +433,14 @@ static int ast_srtp_create(struct ast_srtp **srtp, struct ast_rtp_instance *rtp,
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) {
+ ast_srtp_destroy(temp);
return -1;
}
- ast_module_ref(ast_module_info->self);
temp->rtp = rtp;
*srtp = temp;