aboutsummaryrefslogtreecommitdiffstats
path: root/res/res_odbc.c
diff options
context:
space:
mode:
authorpcadach <pcadach@f38db490-d61c-443f-a65b-d21fe96a405b>2007-01-30 08:34:26 +0000
committerpcadach <pcadach@f38db490-d61c-443f-a65b-d21fe96a405b>2007-01-30 08:34:26 +0000
commitdef7159a0c7b4ef2e37b510d842271b5d464f9c2 (patch)
tree76d23536a68e14babde38f06e2799b20c41d6abb /res/res_odbc.c
parent485930e57eb35cab16bb8c881a07dc087cecae3d (diff)
Don't play with free()'d pointers
git-svn-id: http://svn.digium.com/svn/asterisk/branches/1.4@52808 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'res/res_odbc.c')
-rw-r--r--res/res_odbc.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/res/res_odbc.c b/res/res_odbc.c
index e87190090..34f012de6 100644
--- a/res/res_odbc.c
+++ b/res/res_odbc.c
@@ -360,7 +360,8 @@ static int odbc_register_class(struct odbc_class *class, int connect)
if (connect) {
/* Request and release builds a connection */
obj = ast_odbc_request_obj(class->name, 0);
- ast_odbc_release_obj(obj);
+ if (obj)
+ ast_odbc_release_obj(obj);
}
return 0;
@@ -431,9 +432,10 @@ struct odbc_obj *ast_odbc_request_obj(const char *name, int check)
ast_mutex_init(&obj->lock);
obj->parent = class;
if (odbc_obj_connect(obj) == ODBC_FAIL) {
- ast_log(LOG_WARNING, "Failed to connect\n");
+ ast_log(LOG_WARNING, "Failed to connect to %s\n", name);
ast_mutex_destroy(&obj->lock);
free(obj);
+ obj = NULL;
} else {
AST_LIST_INSERT_HEAD(&class->odbc_obj, obj, list);
}