crypt32: Release a link context's linked context on every release, not just when...
authorJuan Lang <juan.lang@gmail.com>
Sat, 31 Oct 2009 00:32:49 +0000 (17:32 -0700)
committerAlexander Morozov <amorozov@etersoft.ru>
Thu, 1 Jul 2010 13:18:07 +0000 (17:18 +0400)
dlls/crypt32/context.c

index 2f1720abb026246c567c2dda4596f48522c44ee0..109fcd43e8ea51b16367ed4e0744f1947a4a0c13 100644 (file)
@@ -171,25 +171,22 @@ BOOL Context_Release(void *context, size_t contextSize,
 
     if (base->ref <= 0)
         return FALSE;
+    if (base->type == ContextTypeLink)
+    {
+        /* The linked context is of the same type as this, so release
+         * it as well, using the same offset and data free function.
+         */
+        ret = Context_Release(CONTEXT_FROM_BASE_CONTEXT(
+         ((PLINK_CONTEXT)base)->linked, contextSize), contextSize,
+         dataContextFree);
+    }
     if (InterlockedDecrement(&base->ref) == 0)
     {
         TRACE("freeing %p\n", context);
-        switch (base->type)
+        if (base->type == ContextTypeData)
         {
-        case ContextTypeData:
             ContextPropertyList_Free(((PDATA_CONTEXT)base)->properties);
             dataContextFree(context);
-            break;
-        case ContextTypeLink:
-            /* The linked context is of the same type as this, so release
-             * it as well, using the same offset and data free function.
-             */
-            ret = Context_Release(CONTEXT_FROM_BASE_CONTEXT(
-             ((PLINK_CONTEXT)base)->linked, contextSize), contextSize,
-             dataContextFree);
-            break;
-        default:
-            assert(0);
         }
         CryptMemFree(context);
     }