Merge "Fix Memory Leak In OEMCrypto Level 3 Haystack"
This commit is contained in:
committed by
Android (Google) Code Review
commit
88d9472cfb
@@ -233,10 +233,6 @@ class Adapter {
|
||||
Adapter() : level1_valid_(false), level1_library_(NULL) {}
|
||||
|
||||
~Adapter() {
|
||||
for (map_iterator i = session_map_.begin(); i != session_map_.end(); i++) {
|
||||
if (i->second.fcn) i->second.fcn->CloseSession(i->second.session);
|
||||
}
|
||||
session_map_.clear();
|
||||
}
|
||||
|
||||
OEMCryptoResult Initialize() {
|
||||
@@ -405,6 +401,10 @@ class Adapter {
|
||||
}
|
||||
|
||||
OEMCryptoResult Terminate() {
|
||||
for (map_iterator i = session_map_.begin(); i != session_map_.end(); ++i) {
|
||||
if (i->second.fcn) i->second.fcn->CloseSession(i->second.session);
|
||||
}
|
||||
session_map_.clear();
|
||||
OEMCryptoResult result = Level3_Terminate();
|
||||
if (level1_valid_) {
|
||||
result = level1_.Terminate();
|
||||
@@ -602,6 +602,7 @@ OEMCryptoResult OEMCrypto_GetMaxNumberOfSessions(SecurityLevel level,
|
||||
|
||||
extern "C" OEMCryptoResult OEMCrypto_Initialize(void) {
|
||||
if (kAdapter) {
|
||||
kAdapter->Terminate();
|
||||
delete kAdapter;
|
||||
}
|
||||
kAdapter = new Adapter();
|
||||
|
||||
Reference in New Issue
Block a user