зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1232454 - use UniquePtr<T[]> instead of nsAutoArrayPtr<T> in security/apps/; r=keeler
As a nice side effect, we also fix a (rare) memory leak in AppTrustDomain::SetTrustedRoot.
This commit is contained in:
Родитель
c04bec08b0
Коммит
2c2f66f499
|
@ -46,7 +46,7 @@ static char kDevImportedDER[] =
|
|||
namespace mozilla { namespace psm {
|
||||
|
||||
StaticMutex AppTrustDomain::sMutex;
|
||||
nsAutoArrayPtr<unsigned char> AppTrustDomain::sDevImportedDERData(nullptr);
|
||||
UniquePtr<unsigned char[]> AppTrustDomain::sDevImportedDERData;
|
||||
unsigned int AppTrustDomain::sDevImportedDERLen = 0;
|
||||
|
||||
AppTrustDomain::AppTrustDomain(ScopedCERTCertList& certChain, void* pinArg)
|
||||
|
@ -144,18 +144,18 @@ AppTrustDomain::SetTrustedRoot(AppTrustedRoot trustedRoot)
|
|||
return SECFailure;
|
||||
}
|
||||
|
||||
char* data = new char[length];
|
||||
rv = inputStream->Read(data, length, &sDevImportedDERLen);
|
||||
auto data = MakeUnique<char[]>(length);
|
||||
rv = inputStream->Read(data.get(), length, &sDevImportedDERLen);
|
||||
if (NS_FAILED(rv)) {
|
||||
PR_SetError(SEC_ERROR_IO, 0);
|
||||
return SECFailure;
|
||||
}
|
||||
|
||||
MOZ_ASSERT(length == sDevImportedDERLen);
|
||||
sDevImportedDERData = reinterpret_cast<unsigned char*>(data);
|
||||
sDevImportedDERData.reset(reinterpret_cast<unsigned char*>(data.release()));
|
||||
}
|
||||
|
||||
trustedDER.data = sDevImportedDERData;
|
||||
trustedDER.data = sDevImportedDERData.get();
|
||||
trustedDER.len = sDevImportedDERLen;
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
|
||||
#include "pkix/pkixtypes.h"
|
||||
#include "mozilla/StaticMutex.h"
|
||||
#include "nsAutoPtr.h"
|
||||
#include "mozilla/UniquePtr.h"
|
||||
#include "nsDebug.h"
|
||||
#include "nsIX509CertDB.h"
|
||||
#include "ScopedNSSTypes.h"
|
||||
|
@ -73,7 +73,7 @@ private:
|
|||
unsigned int mMinRSABits;
|
||||
|
||||
static StaticMutex sMutex;
|
||||
static nsAutoArrayPtr<unsigned char> sDevImportedDERData;
|
||||
static UniquePtr<unsigned char[]> sDevImportedDERData;
|
||||
static unsigned int sDevImportedDERLen;
|
||||
};
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче