Skip to content

Commit

Permalink
fixing coverity found defects - null dereference, break missing
Browse files Browse the repository at this point in the history
(cherry picked from commit c004967)

Conflicts:
	db/db.c
  • Loading branch information
ph4r05 authored and liviuchircu committed Jan 14, 2016
1 parent a152bdf commit ed699bf
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 10 deletions.
13 changes: 6 additions & 7 deletions db/db.c
Expand Up @@ -263,18 +263,17 @@ int db_bind_mod(const str* mod, db_func_t* mydbf)
*/
db_con_t* db_do_init(const str* url, void* (*new_connection)())
{
struct db_id* id;
struct pool_con* con;
db_con_t* res;

int con_size = sizeof(db_con_t) + sizeof(void *) + url->len;
id = 0;
res = 0;
struct db_id *id = NULL;
struct pool_con *con = NULL;
db_con_t *res = NULL;
int con_size = 0;

if (!url || !url->s || !new_connection) {
LM_ERR("invalid parameter value\n");
return 0;
}

con_size = sizeof(db_con_t) + sizeof(void *) + url->len;
if (url->len > MAX_URL_LENGTH)
{
LM_ERR("SQL URL too long\n");
Expand Down
2 changes: 1 addition & 1 deletion evi/event_interface.c
Expand Up @@ -509,7 +509,7 @@ struct mi_root * mi_events_list(struct mi_root *cmd_tree, void *param)

static int evi_print_subscriber(struct mi_node *rpl, evi_subs_p subs)
{
evi_reply_sock *sock = subs->reply_sock;
evi_reply_sock *sock = subs != NULL ? subs->reply_sock : NULL;
struct mi_node *node = NULL;
str socket;

Expand Down
1 change: 1 addition & 0 deletions main.c
Expand Up @@ -881,6 +881,7 @@ int main(int argc, char** argv)
break;
case 'R':
received_dns|=DO_REV_DNS;
break;
case 'd':
(*debug)++;
break;
Expand Down
2 changes: 1 addition & 1 deletion modules/alias_db/alookup.c
Expand Up @@ -119,7 +119,7 @@ static int alias_db_query(struct sip_msg* _msg, char* _table,
goto err_server;
}

if (RES_ROW_N(db_res)<=0 || RES_ROWS(db_res)[0].values[0].nul != 0) {
if (db_res == NULL || RES_ROW_N(db_res)<=0 || RES_ROWS(db_res)[0].values[0].nul != 0) {
LM_DBG("no alias found for R-URI\n");
if (db_res!=NULL && adbf.free_result(db_handle, db_res) < 0)
LM_DBG("failed to freeing result of query\n");
Expand Down
2 changes: 1 addition & 1 deletion modules/usrloc/dlist.c
Expand Up @@ -195,7 +195,7 @@ static int get_all_db_ucontacts(void *buf, int len, unsigned int flags,
row = RES_ROWS(res) + i;
val = ROW_VALUES(row) + 3; /* cflags */
flag_list.s = (char *)VAL_STRING(val);
flag_list.len = strlen(flag_list.s);
flag_list.len = (val->nul || !flag_list.s) ? 0 : strlen(flag_list.s);

LM_DBG("contact cflags: '%.*s'\n", flag_list.len, flag_list.s);

Expand Down

0 comments on commit ed699bf

Please sign in to comment.