P2P: Reorder code to avoid memory leak on error path

This commit is contained in:
Jouni Malinen 2010-10-31 12:24:21 +02:00
parent d25f7212da
commit 79222cfa61

View file

@ -1309,13 +1309,6 @@ static void wpas_sd_req_upnp(struct wpa_supplicant *wpa_s,
return; return;
} }
version = query[0];
str = os_malloc(query_len);
if (str == NULL)
return;
os_memcpy(str, query + 1, query_len - 1);
str[query_len - 1] = '\0';
if (wpabuf_tailroom(resp) < 5) if (wpabuf_tailroom(resp) < 5)
return; return;
@ -1324,6 +1317,13 @@ static void wpas_sd_req_upnp(struct wpa_supplicant *wpa_s,
wpabuf_put_u8(resp, P2P_SERV_UPNP); wpabuf_put_u8(resp, P2P_SERV_UPNP);
wpabuf_put_u8(resp, srv_trans_id); wpabuf_put_u8(resp, srv_trans_id);
version = query[0];
str = os_malloc(query_len);
if (str == NULL)
return;
os_memcpy(str, query + 1, query_len - 1);
str[query_len - 1] = '\0';
dl_list_for_each(usrv, &wpa_s->global->p2p_srv_upnp, dl_list_for_each(usrv, &wpa_s->global->p2p_srv_upnp,
struct p2p_srv_upnp, list) { struct p2p_srv_upnp, list) {
if (version != usrv->version) if (version != usrv->version)