Bug 505723 nsWifiMonitor::DoScan seems to leak iwlib_handle after ReplaceArray(lastAccessPoints, accessPoints)

r=dougt
This commit is contained in:
timeless@mozdev.org 2009-08-12 11:49:53 +02:00
Родитель 13738cdd09
Коммит e5afce9f26
1 изменённых файлов: 9 добавлений и 11 удалений

Просмотреть файл

@ -66,14 +66,10 @@ typedef int (*iw_stats_t)(int skfd,
const iwrange *range,
int has_range);
static iw_open_t iw_open = nsnull;
static iw_enum_t iw_enum = nsnull;
static iw_stats_t iw_stats = nsnull;
static int scan_wifi(int skfd, char* ifname, char* args[], int count)
{
nsCOMArray<nsWifiAccessPoint>* accessPoints = (nsCOMArray<nsWifiAccessPoint>*) args[0];
iw_stats_t iw_stats = (iw_stats_t) args[1];
struct iwreq wrq;
@ -140,9 +136,9 @@ nsWifiMonitor::DoScan()
LOG(("Loaded libiw\n"));
}
iw_open = (iw_open_t) dlsym(iwlib_handle, "iw_sockets_open");
iw_enum = (iw_enum_t) dlsym(iwlib_handle, "iw_enum_devices");
iw_stats = (iw_stats_t)dlsym(iwlib_handle, "iw_get_stats");
iw_open_t iw_open = (iw_open_t) dlsym(iwlib_handle, "iw_sockets_open");
iw_enum_t iw_enum = (iw_enum_t) dlsym(iwlib_handle, "iw_enum_devices");
iw_stats_t iw_stats = (iw_stats_t)dlsym(iwlib_handle, "iw_get_stats");
if (!iw_open || !iw_enum || !iw_stats) {
dlclose(iwlib_handle);
@ -160,7 +156,7 @@ nsWifiMonitor::DoScan()
nsCOMArray<nsWifiAccessPoint> lastAccessPoints;
nsCOMArray<nsWifiAccessPoint> accessPoints;
char* args[] = {(char*) &accessPoints, nsnull };
char* args[] = {(char*) &accessPoints, (char*) iw_stats, nsnull };
while (mKeepGoing == PR_TRUE) {
@ -188,9 +184,11 @@ nsWifiMonitor::DoScan()
{
PRUint32 resultCount = lastAccessPoints.Count();
nsIWifiAccessPoint** result = static_cast<nsIWifiAccessPoint**> (nsMemory::Alloc(sizeof(nsIWifiAccessPoint*) * resultCount));
if (!result)
if (!result) {
dlclose(iwlib_handle);
return NS_ERROR_OUT_OF_MEMORY;
}
for (PRUint32 i = 0; i < resultCount; i++)
result[i] = lastAccessPoints[i];