Module: kamailio
Branch: master
Commit: 1ed223dcccf4c2ea623db75fdda16adc924b916e
URL:
https://github.com/kamailio/kamailio/commit/1ed223dcccf4c2ea623db75fdda16ad…
Author: Daniel-Constantin Mierla <miconda(a)gmail.com>
Committer: Daniel-Constantin Mierla <miconda(a)gmail.com>
Date: 2017-07-21T08:57:39+02:00
speeddial: simplified access to db_res and the free of it
---
Modified: src/modules/speeddial/sdlookup.c
---
Diff:
https://github.com/kamailio/kamailio/commit/1ed223dcccf4c2ea623db75fdda16ad…
Patch:
https://github.com/kamailio/kamailio/commit/1ed223dcccf4c2ea623db75fdda16ad…
---
diff --git a/src/modules/speeddial/sdlookup.c b/src/modules/speeddial/sdlookup.c
index c4f655efce..d9e52bf3cd 100644
--- a/src/modules/speeddial/sdlookup.c
+++ b/src/modules/speeddial/sdlookup.c
@@ -161,17 +161,17 @@ int sd_lookup_owner(sip_msg_t* _msg, str* stable, str* sowner)
db_funcs.use_table(db_handle, &table_s);
if(db_funcs.query(db_handle, db_keys, NULL, db_vals, db_cols,
- nr_keys /*no keys*/, 1 /*no cols*/, NULL, &db_res)!=0)
+ nr_keys /*no keys*/, 1 /*no cols*/, NULL, &db_res)!=0 || db_res==NULL)
{
LM_ERR("failed to query database\n");
goto err_server;
}
- if (RES_ROW_N(db_res)<=0 || RES_ROWS(db_res)[0].values[0].nul != 0)
- {
+ if(RES_ROW_N(db_res) <= 0 || RES_ROWS(db_res)[0].values[0].nul != 0) {
LM_DBG("no sip address found for R-URI\n");
- if (db_res!=NULL && db_funcs.free_result(db_handle, db_res) < 0)
+ if(db_funcs.free_result(db_handle, db_res) < 0) {
LM_DBG("failed to free result of query\n");
+ }
return -1;
}
@@ -199,8 +199,7 @@ int sd_lookup_owner(sip_msg_t* _msg, str* stable, str* sowner)
break;
default:
LM_ERR("unknown type of DB new_uri column\n");
- if (db_res != NULL && db_funcs.free_result(db_handle, db_res) < 0)
- {
+ if (db_funcs.free_result(db_handle, db_res) < 0) {
LM_DBG("failed to free result of query\n");
}
goto err_server;
@@ -217,8 +216,9 @@ int sd_lookup_owner(sip_msg_t* _msg, str* stable, str* sowner)
/**
* Free the result because we don't need it anymore
*/
- if (db_res!=NULL && db_funcs.free_result(db_handle, db_res) < 0)
+ if (db_funcs.free_result(db_handle, db_res) < 0) {
LM_DBG("failed to free result of query\n");
+ }
/* set the URI */
LM_DBG("URI of sd from R-URI [%s]\n", user_s.s);