From 40167afef4d8a885aa89d55b0a3e5f0738bae600 Mon Sep 17 00:00:00 2001 From: "[CST] Focus" Date: Wed, 16 Jul 2014 11:52:24 +0400 Subject: [PATCH] libiw/iwscan.cpp: fix crash in case of different cmd order --- lib/libiw/iwscan.cpp | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/lib/libiw/iwscan.cpp b/lib/libiw/iwscan.cpp index ab39a56e2..45efd2b4d 100644 --- a/lib/libiw/iwscan.cpp +++ b/lib/libiw/iwscan.cpp @@ -219,6 +219,11 @@ realloc: if (ret <= 0) break; switch(event->cmd) { + case SIOCGIWAP: + count++; + networks.push_back(network); + printf(" Network %d:\n", count+1); + break; case SIOCGIWESSID: { char essid[IW_ESSID_MAX_SIZE+1]; @@ -228,14 +233,12 @@ realloc: if(event->u.essid.flags) { printf(" ESSID:\"%s\"\n", essid); - network.ssid = essid; + networks[count].ssid = essid; } else { printf(" ESSID:off/any/hidden\n"); - network.ssid = "(hidden)"; + networks[count].ssid = "(hidden)"; } - count++; - networks.push_back(network); } break;