зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1047757: Call ClearOnShutdown(sBluetoothService) to fix memory leak. r=shuang
This commit is contained in:
Родитель
f984628edc
Коммит
763f8f19a9
|
@ -20,6 +20,7 @@
|
|||
#include "BluetoothUtils.h"
|
||||
|
||||
#include "jsapi.h"
|
||||
#include "mozilla/ClearOnShutdown.h"
|
||||
#include "mozilla/Services.h"
|
||||
#include "mozilla/StaticPtr.h"
|
||||
#include "mozilla/unused.h"
|
||||
|
@ -732,15 +733,15 @@ BluetoothService::Get()
|
|||
}
|
||||
|
||||
// Create new instance, register, return
|
||||
nsRefPtr<BluetoothService> service = BluetoothService::Create();
|
||||
NS_ENSURE_TRUE(service, nullptr);
|
||||
sBluetoothService = BluetoothService::Create();
|
||||
NS_ENSURE_TRUE(sBluetoothService, nullptr);
|
||||
|
||||
if (!service->Init()) {
|
||||
service->Cleanup();
|
||||
if (!sBluetoothService->Init()) {
|
||||
sBluetoothService->Cleanup();
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
sBluetoothService = service;
|
||||
ClearOnShutdown(&sBluetoothService);
|
||||
return sBluetoothService;
|
||||
}
|
||||
|
||||
|
|
|
@ -20,6 +20,7 @@
|
|||
#include "BluetoothUtils.h"
|
||||
|
||||
#include "jsapi.h"
|
||||
#include "mozilla/ClearOnShutdown.h"
|
||||
#include "mozilla/Services.h"
|
||||
#include "mozilla/StaticPtr.h"
|
||||
#include "mozilla/unused.h"
|
||||
|
@ -663,15 +664,15 @@ BluetoothService::Get()
|
|||
}
|
||||
|
||||
// Create new instance, register, return
|
||||
nsRefPtr<BluetoothService> service = BluetoothService::Create();
|
||||
NS_ENSURE_TRUE(service, nullptr);
|
||||
sBluetoothService = BluetoothService::Create();
|
||||
NS_ENSURE_TRUE(sBluetoothService, nullptr);
|
||||
|
||||
if (!service->Init()) {
|
||||
service->Cleanup();
|
||||
if (!sBluetoothService->Init()) {
|
||||
sBluetoothService->Cleanup();
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
sBluetoothService = service;
|
||||
ClearOnShutdown(&sBluetoothService);
|
||||
return sBluetoothService;
|
||||
}
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче