crypt32(7/13): Release a link context's linked context on every release, not just when it reaches 0

View: New views
1 Messages — Rating Filter:   Alert me  

crypt32(7/13): Release a link context's linked context on every release, not just when it reaches 0

by Juan Lang-4 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

This balances the add-refs done in the prior two patches.
--Juan

[0007-Release-a-link-context-s-linked-context-on-every-rel.patch]

From 41c43f1f08afd81abf557c78d095d686f6faea40 Mon Sep 17 00:00:00 2001
From: Juan Lang <juan.lang@...>
Date: Fri, 30 Oct 2009 17:32:49 -0700
Subject: [PATCH] Release a link context's linked context on every release, not just when it reaches 0

---
 dlls/crypt32/context.c |   23 ++++++++++-------------
 1 files changed, 10 insertions(+), 13 deletions(-)

diff --git a/dlls/crypt32/context.c b/dlls/crypt32/context.c
index 2f1720a..109fcd4 100644
--- a/dlls/crypt32/context.c
+++ b/dlls/crypt32/context.c
@@ -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);
     }
--
1.6.0.6