Bug 1208405 - [CID 222169] leaked_storage: Variable fwObject going out of scope leaks the storage it points to, r=mt
authorFranziskus Kiefer <franziskuskiefer@gmail.com>
Tue, 20 Oct 2015 14:59:48 +0200
changeset 11690 bbbea9edea2b87c89262dd312d3156aca9a038a2
parent 11689 4f05e85715d7a29b6ebaa836175234561f1072d6
child 11691 ad5687c22dff6e727f0b8a5c12b65fb0923c71d1
push id831
push usermartin.thomson@gmail.com
push dateTue, 20 Oct 2015 17:34:18 +0000
reviewersmt
bugs1208405, 222169
Bug 1208405 - [CID 222169] leaked_storage: Variable fwObject going out of scope leaks the storage it points to, r=mt
lib/ckfw/object.c
--- a/lib/ckfw/object.c
+++ b/lib/ckfw/object.c
@@ -166,16 +166,17 @@ nssCKFWObject_Create
   fwObject->mdToken = nssCKFWToken_GetMDToken(fwToken);
   fwObject->fwInstance = fwInstance;
   fwObject->mdInstance = nssCKFWInstance_GetMDInstance(fwInstance);
   fwObject->mutex = nssCKFWInstance_CreateMutex(fwInstance, arena, pError);
   if (!fwObject->mutex) {
     if( CKR_OK == *pError ) {
       *pError = CKR_GENERAL_ERROR;
     }
+    nss_ZFreeIf(fwObject);
     return (NSSCKFWObject *)NULL;
   }
 
   *pError = nssCKFWHash_Add(mdObjectHash, mdObject, fwObject);
   if( CKR_OK != *pError ) {
     nss_ZFreeIf(fwObject);
     return (NSSCKFWObject *)NULL;
   }