Fixed NULL pointer deference in bt-service/bt-service-obex-agent.c 83/42083/1
authorAnchit Narang <anchit.n@samsung.com>
Tue, 23 Jun 2015 04:59:43 +0000 (10:29 +0530)
committerAnchit Narang <anchit.n@samsung.com>
Tue, 23 Jun 2015 04:59:43 +0000 (10:29 +0530)
Added NULL check after malloc to prevent bt-service crash if
enough memory cannot be allocated

Change-Id: Ia59ea7512107ceb4886b60183a7228bd7524520b

bt-service/bt-service-obex-agent.c

index 6a988b3..174373e 100644 (file)
@@ -389,6 +389,10 @@ void _bt_obex_agent_new(char *path)
                }
        }
        info = (bt_obex_agent_info *)malloc (sizeof(bt_obex_agent_info));
+       if (info == NULL) {
+               BT_ERR("Failed to allocate memory");
+               return;
+       }
        memset(info, 0, sizeof(bt_obex_agent_info));
        info->path = g_strdup(path);
        obex_agent_list = g_slist_append(obex_agent_list, info);