summaryrefslogtreecommitdiff
path: root/res/res_sorcery_memory_cache.c
diff options
context:
space:
mode:
authorRichard Mudgett <rmudgett@digium.com>2015-11-30 14:22:55 -0600
committerRichard Mudgett <rmudgett@digium.com>2015-12-01 13:53:18 -0600
commitbb0b60619daddb1448e980f9067780bcd6ca5e35 (patch)
tree6f9c68b421e280fc8e3633c37e58ea4937729779 /res/res_sorcery_memory_cache.c
parente7c88e11aa753e046fe58a19ac82320c81cc6e2b (diff)
res_sorcery_memory_cache.c: Fix off nominal ref leak.
Change-Id: If83d63cf11cbc6df9b15251848b01feb570ade49
Diffstat (limited to 'res/res_sorcery_memory_cache.c')
-rw-r--r--res/res_sorcery_memory_cache.c11
1 files changed, 7 insertions, 4 deletions
diff --git a/res/res_sorcery_memory_cache.c b/res/res_sorcery_memory_cache.c
index 0ce0e33a1..58aaada41 100644
--- a/res/res_sorcery_memory_cache.c
+++ b/res/res_sorcery_memory_cache.c
@@ -848,13 +848,16 @@ static void *sorcery_memory_cache_retrieve_id(const struct ast_sorcery *sorcery,
if (cached->stale_update_sched_id == -1) {
struct stale_update_task_data *task_data;
- task_data = stale_update_task_data_alloc((struct ast_sorcery *)sorcery, cache,
- type, cached->object);
+ task_data = stale_update_task_data_alloc((struct ast_sorcery *) sorcery,
+ cache, type, cached->object);
if (task_data) {
ast_debug(1, "Cached sorcery object type '%s' ID '%s' is stale. Refreshing\n",
type, id);
- cached->stale_update_sched_id = ast_sched_add(sched, 1, stale_item_update, task_data);
- } else {
+ cached->stale_update_sched_id = ast_sched_add(sched, 1,
+ stale_item_update, task_data);
+ }
+ if (cached->stale_update_sched_id < 0) {
+ ao2_cleanup(task_data);
ast_log(LOG_ERROR, "Unable to update stale cached object type '%s', ID '%s'.\n",
type, id);
}