Commits

Anonymous committed d20d04b

sb144: #i117884# do not leak phSubKeys if nSubKeys == 0

Comments (0)

Files changed (1)

registry/source/regkey.cxx

 RegError REGISTRY_CALLTYPE closeSubKeys(RegKeyHandle* phSubKeys,
 										sal_uInt32 nSubKeys)
 {
-	if (phSubKeys == 0 || nSubKeys == 0)
+	if (phSubKeys == 0)
 		return REG_INVALID_KEY;
 
-	ORegistry* pReg = ((ORegKey*)(phSubKeys[0]))->getRegistry();
-	for (sal_uInt32 i = 0; i < nSubKeys; i++)
-	{
-		(void) pReg->closeKey(phSubKeys[i]);
-	}
+    if (nSubKeys != 0)
+    {
+        ORegistry* pReg = ((ORegKey*)(phSubKeys[0]))->getRegistry();
+        for (sal_uInt32 i = 0; i < nSubKeys; i++)
+        {
+            (void) pReg->closeKey(phSubKeys[i]);
+        }
+    }
 	rtl_freeMemory(phSubKeys);
 
 	return REG_NO_ERROR;