From cf51e75a62957c8bfd89bb4f655ee9623a870e70 Mon Sep 17 00:00:00 2001 From: "wchang0222%aol.com" Date: Fri, 19 Dec 2003 19:36:30 +0000 Subject: [PATCH] Bugscape bug 54500: Improved the previous checkin: fixed leaks of the return values of PK11_GetSymKeyNickname. Removed unnecessary assignment statements "symKeyObj = NULL;". Removed an unnecessary else { }. git-svn-id: svn://10.0.0.236/trunk@150524 18797224-902f-48f8-a5cc-f745e15eee43 --- .../jss/SecretDecoderRing/KeyManager.c | 46 +++++++++---------- 1 file changed, 23 insertions(+), 23 deletions(-) diff --git a/mozilla/security/jss/org/mozilla/jss/SecretDecoderRing/KeyManager.c b/mozilla/security/jss/org/mozilla/jss/SecretDecoderRing/KeyManager.c index c10c8e1961d..f9e3ac0a805 100644 --- a/mozilla/security/jss/org/mozilla/jss/SecretDecoderRing/KeyManager.c +++ b/mozilla/security/jss/org/mozilla/jss/SecretDecoderRing/KeyManager.c @@ -283,6 +283,7 @@ Java_org_mozilla_jss_SecretDecoderRing_KeyManager_lookupUniqueNamedKeyNative keys_found++; } } + PORT_Free(name); } nextSymKey = PK11_GetNextSymKey( /* symmetric key */ symKey ); @@ -295,7 +296,6 @@ Java_org_mozilla_jss_SecretDecoderRing_KeyManager_lookupUniqueNamedKeyNative /* case 1: the token is empty */ if( count == 0 ) { /* the specified token is empty */ - symKeyObj = NULL; goto finish; } @@ -303,41 +303,41 @@ Java_org_mozilla_jss_SecretDecoderRing_KeyManager_lookupUniqueNamedKeyNative if( ( keyname != NULL ) && ( keys_found == 0 ) ) { /* the key called "keyname" could not be found */ - symKeyObj = NULL; goto finish; } /* case 3: the specified key exists more than once on this token */ if( keys_found != 1 ) { /* more than one key called "keyname" was found on this token */ - symKeyObj = NULL; JSS_throwMsgPrErr(env, TOKEN_EXCEPTION, "Duplicate named keys exist on this token"); goto finish; - } else { - /* Re-initialize the symmetric key list. */ - symKey = PK11_ListFixedKeysInSlot( - /* slot */ slot, - /* nickname */ NULL, - /* wincx */ NULL ); + } - /* Reiterate through the symmetric key list once more, */ - /* this time returning an actual reference to the key. */ - while( symKey != NULL ) { - name = PK11_GetSymKeyNickname( /* symmetric key */ symKey ); - if( name != NULL ) { - if( keyname != NULL ) { - if( PL_strcmp( keyname, name ) == 0 ) { - symKeyObj = JSS_PK11_wrapSymKey(env, &symKey); - goto finish; - } + /* Re-initialize the symmetric key list. */ + symKey = PK11_ListFixedKeysInSlot( + /* slot */ slot, + /* nickname */ NULL, + /* wincx */ NULL ); + + /* Reiterate through the symmetric key list once more, */ + /* this time returning an actual reference to the key. */ + while( symKey != NULL ) { + name = PK11_GetSymKeyNickname( /* symmetric key */ symKey ); + if( name != NULL ) { + if( keyname != NULL ) { + if( PL_strcmp( keyname, name ) == 0 ) { + symKeyObj = JSS_PK11_wrapSymKey(env, &symKey); + PORT_Free(name); + goto finish; } } - - nextSymKey = PK11_GetNextSymKey( /* symmetric key */ symKey ); - PK11_FreeSymKey( /* symmetric key */ symKey ); - symKey = nextSymKey; + PORT_Free(name); } + + nextSymKey = PK11_GetNextSymKey( /* symmetric key */ symKey ); + PK11_FreeSymKey( /* symmetric key */ symKey ); + symKey = nextSymKey; }