]> git.ipfire.org Git - thirdparty/asterisk.git/commitdiff
res_sorcery_memory_cache.c: Fix off nominal ref leak. 44/1744/2
authorRichard Mudgett <rmudgett@digium.com>
Mon, 30 Nov 2015 20:22:55 +0000 (14:22 -0600)
committerRichard Mudgett <rmudgett@digium.com>
Tue, 1 Dec 2015 19:53:18 +0000 (13:53 -0600)
Change-Id: If83d63cf11cbc6df9b15251848b01feb570ade49

res/res_sorcery_memory_cache.c

index 0ce0e33a13e4745f59ef24d24774bc5f7a3410d4..58aaada41e5a32dd6366d23728d85ca3be0a343e 100644 (file)
@@ -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);
                                }