]> git.ipfire.org Git - thirdparty/asterisk.git/commitdiff
Don't crash when the connection fails.
authorTilghman Lesher <tilghman@meg.abyt.es>
Sun, 22 May 2011 23:25:51 +0000 (23:25 +0000)
committerTilghman Lesher <tilghman@meg.abyt.es>
Sun, 22 May 2011 23:25:51 +0000 (23:25 +0000)
(closes issue #19250)
 Reported by: seadweller
 Patches:
       20110514__issue19250.diff.txt uploaded by tilghman (license 14)
 Tested by: seadweller, sum

git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.6.2@320444 65c4cc65-6c06-0410-ace0-fbb531ad65f3

res/res_odbc.c

index c6bbd7a57e2fb76b56c764fafeb0b07c5a81fad1..6d76f1b81d6ee52b5b2db9bb3039f19bdefe9827 100644 (file)
@@ -1191,10 +1191,11 @@ struct odbc_obj *ast_odbc_request_obj2(const char *name, struct ast_flags flags)
                        class = NULL;
                        if (odbc_obj_connect(obj) == ODBC_FAIL) {
                                ast_log(LOG_WARNING, "Failed to connect to %s\n", name);
+                               ast_assert(ao2_ref(obj->parent, 0) > 0);
+                               /* Because it was never within the container, we have to manually decrement the count here */
+                               ast_atomic_fetchadd_int(&obj->parent->count, -1);
                                ao2_ref(obj, -1);
                                obj = NULL;
-                               ast_assert(ao2_ref(class, 0) > 0);
-                               ast_atomic_fetchadd_int(&class->count, -1);
                        } else {
                                obj->used = 1;
                                ao2_link(obj->parent->obj_container, obj);