]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
P2P: Reorder code to avoid memory leak on error path
authorJouni Malinen <j@w1.fi>
Sun, 31 Oct 2010 10:24:21 +0000 (12:24 +0200)
committerJouni Malinen <j@w1.fi>
Sun, 31 Oct 2010 10:24:21 +0000 (12:24 +0200)
wpa_supplicant/p2p_supplicant.c

index 6f074595b611e8338e17a3553a8078ae78ced5b8..1219f690c3be0f17f7f4e0375fa9baf2d799f1d9 100644 (file)
@@ -1309,13 +1309,6 @@ static void wpas_sd_req_upnp(struct wpa_supplicant *wpa_s,
                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)
                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, 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,
                         struct p2p_srv_upnp, list) {
                if (version != usrv->version)