]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
WPS: Fix a memory leak if set_ie_cb() is not set
authorJouni Malinen <j@w1.fi>
Thu, 24 Dec 2009 23:29:59 +0000 (01:29 +0200)
committerJouni Malinen <j@w1.fi>
Thu, 24 Dec 2009 23:29:59 +0000 (01:29 +0200)
Skip WPS IE building for Beacon and Probe Response frames is set_ie_cb()
is not set. This fixes a memory leak and optimizes operations by not
allocating memory and building the WPS IEs unnecessarily.

src/wps/wps_registrar.c

index fbc4e77f2a63230db1f2c2f2f78f2ad040716a62..07e65462ecf8bf71bdb23054690fbf8c17c8e51a 100644 (file)
@@ -819,9 +819,6 @@ static void wps_cb_reg_success(struct wps_registrar *reg, const u8 *mac_addr,
 static int wps_cb_set_ie(struct wps_registrar *reg, struct wpabuf *beacon_ie,
                         struct wpabuf *probe_resp_ie)
 {
-       if (reg->set_ie_cb == NULL)
-               return 0;
-
        return reg->set_ie_cb(reg->cb_ctx, beacon_ie, probe_resp_ie);
 }
 
@@ -881,6 +878,9 @@ static int wps_set_ie(struct wps_registrar *reg)
        struct wpabuf *beacon;
        struct wpabuf *probe;
 
+       if (reg->set_ie_cb == NULL)
+               return 0;
+
        wpa_printf(MSG_DEBUG, "WPS: Build Beacon and Probe Response IEs");
 
        beacon = wpabuf_alloc(300);