Fix Memory Leak In OEMCrypto Level 3 Haystack
Merge from Widevine repo of http://go/wvgerrit/10308 There was a memory leak in the oemcrypto RSA code. Also, when saving the usage table, some session variables were allocated twice. This results in session data being lost. There were also some leaks and uninitialized values in oemcrypto_test. I added some checks and profiling to the debug runtime for the haystack. It will warn if a variable is left unencrypted or is unencrypted twice. I also added the profile code. Versions of L3 library: android/level3/arm/libwvlevel3.a Level3 Library Apr 1 2015 11:40:06 android/level3/x86/libwvlevel3.a Level3 Library Apr 1 2015 12:44:32 b/19950814 Change-Id: Ic752e36c09fce121dcaf92f9209591e74f3eb070
This commit is contained in:
@@ -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