Skip to content

Commit 756ebee

Browse files
pennamfacchinm
authored andcommitted
Cleanup ap_list before scanning
1 parent ddfb0a8 commit 756ebee

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

libraries/WiFi/src/WiFi.cpp

+3-2
Original file line numberDiff line numberDiff line change
@@ -162,9 +162,10 @@ static uint8_t sec2enum(nsapi_security_t sec) {
162162

163163
int8_t arduino::WiFiClass::scanNetworks() {
164164
uint8_t count = 10;
165-
if (ap_list == nullptr) {
166-
ap_list = new WiFiAccessPoint[count];
165+
if (ap_list != nullptr) {
166+
free(ap_list);
167167
}
168+
ap_list = new WiFiAccessPoint[count];
168169
return wifi_if->scan(ap_list, count);
169170
}
170171

0 commit comments

Comments
 (0)