Fix cleanup code in Decrypt to check for NULL pointers
authorthayes%netscape.com
Mon, 12 Jun 2000 20:19:39 +0000
changeset 355 13d7b925a93d592f7754fdd2c56a250a5ace386e
parent 354 95cc06896665e3f23f4c4e66bc48e67175739bd4
child 357 b147bdd7e823a8c17573ee49ba5b594473d70f94
push idunknown
push userunknown
push dateunknown
Fix cleanup code in Decrypt to check for NULL pointers
security/nss/lib/pk11wrap/pk11sdr.c
--- a/security/nss/lib/pk11wrap/pk11sdr.c
+++ b/security/nss/lib/pk11wrap/pk11sdr.c
@@ -273,16 +273,16 @@ PK11SDR_Decrypt(SECItem *data, SECItem *
   PK11_Finalize(ctx);
 
   /* Remove the padding */
   rv = unpadBlock(&paddedResult, PK11_GetBlockSize(type, 0), result);
   if (rv) goto loser;
 
 loser:
   SECITEM_ZfreeItem(&paddedResult, PR_FALSE);
-  PORT_FreeArena(arena, PR_TRUE);
-  PK11_DestroyContext(ctx, PR_TRUE);
-  PK11_FreeSymKey(key);
-  SECITEM_ZfreeItem(params, PR_TRUE);
-  PK11_FreeSlot(slot);
+  if (arena) PORT_FreeArena(arena, PR_TRUE);
+  if (ctx) PK11_DestroyContext(ctx, PR_TRUE);
+  if (key) PK11_FreeSymKey(key);
+  if (params) SECITEM_ZfreeItem(params, PR_TRUE);
+  if (slot) PK11_FreeSlot(slot);
 
   return rv;
 }