libiw/iwscan.cpp: fix crash in case of different cmd order

This commit is contained in:
[CST] Focus
2014-07-16 11:52:24 +04:00
parent de91201fa2
commit 40167afef4

View File

@@ -219,6 +219,11 @@ realloc:
if (ret <= 0) if (ret <= 0)
break; break;
switch(event->cmd) { switch(event->cmd) {
case SIOCGIWAP:
count++;
networks.push_back(network);
printf(" Network %d:\n", count+1);
break;
case SIOCGIWESSID: case SIOCGIWESSID:
{ {
char essid[IW_ESSID_MAX_SIZE+1]; char essid[IW_ESSID_MAX_SIZE+1];
@@ -228,14 +233,12 @@ realloc:
if(event->u.essid.flags) if(event->u.essid.flags)
{ {
printf(" ESSID:\"%s\"\n", essid); printf(" ESSID:\"%s\"\n", essid);
network.ssid = essid; networks[count].ssid = essid;
} }
else { else {
printf(" ESSID:off/any/hidden\n"); printf(" ESSID:off/any/hidden\n");
network.ssid = "(hidden)"; networks[count].ssid = "(hidden)";
} }
count++;
networks.push_back(network);
} }
break; break;