Juan Lang : crypt32: If a decoding function failed, free the memory allocated for it.

Alexandre Julliard julliard at winehq.org
Fri Nov 9 07:44:10 CST 2007


Module: wine
Branch: master
Commit: 2e4242b5453e661e186697a166cee259805f5ddc
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=2e4242b5453e661e186697a166cee259805f5ddc

Author: Juan Lang <juan.lang at gmail.com>
Date:   Thu Nov  8 08:55:36 2007 -0800

crypt32: If a decoding function failed, free the memory allocated for it.

---

 dlls/crypt32/decode.c |   12 ++++++++++++
 1 files changed, 12 insertions(+), 0 deletions(-)

diff --git a/dlls/crypt32/decode.c b/dlls/crypt32/decode.c
index 8ceceac..3697c8a 100644
--- a/dlls/crypt32/decode.c
+++ b/dlls/crypt32/decode.c
@@ -231,6 +231,14 @@ static BOOL CRYPT_DecodeEnsureSpace(DWORD dwFlags,
     return ret;
 }
 
+static void CRYPT_FreeSpace(PCRYPT_DECODE_PARA pDecodePara, LPVOID pv)
+{
+    if (pDecodePara && pDecodePara->pfnFree)
+        pDecodePara->pfnFree(pv);
+    else
+        LocalFree(pv);
+}
+
 /* Helper function to check *pcbStructInfo and set it to the required size.
  * Assumes pvStructInfo is not NULL.
  */
@@ -540,6 +548,8 @@ static BOOL CRYPT_AsnDecodeSequence(struct AsnDecodeSequenceItem items[],
                     ret = CRYPT_AsnDecodeSequenceItems(items, cItem,
                      ptr, dataLen, dwFlags, pvStructInfo, nextData,
                      &cbDecoded);
+                    if (!ret && (dwFlags & CRYPT_DECODE_ALLOC_FLAG))
+                        CRYPT_FreeSpace(pDecodePara, pvStructInfo);
                 }
             }
         }
@@ -727,6 +737,8 @@ static BOOL CRYPT_AsnDecodeArray(const struct AsnArrayDescriptor *arrayDesc,
                             ptr += itemDecoded;
                         }
                     }
+                    if (!ret && (dwFlags & CRYPT_DECODE_ALLOC_FLAG))
+                        CRYPT_FreeSpace(pDecodePara, pvStructInfo);
                 }
             }
             if (itemSizes != &itemSize)




More information about the wine-cvs mailing list