Commit 1799ceb8 authored by Juan Lang's avatar Juan Lang Committed by Alexandre Julliard

crypt32: Free memory using the correct function on failure.

parent 9423f836
......@@ -1561,6 +1561,14 @@ static BOOL CRYPT_AsnEncodeUnicodeStringCoerce(const CERT_NAME_VALUE *value,
return ret;
}
static void CRYPT_FreeSpace(PCRYPT_ENCODE_PARA pEncodePara, LPVOID pv)
{
if (pEncodePara && pEncodePara->pfnFree)
pEncodePara->pfnFree(pv);
else
LocalFree(pv);
}
static BOOL CRYPT_AsnEncodeNumericString(const CERT_NAME_VALUE *value,
DWORD dwFlags, PCRYPT_ENCODE_PARA pEncodePara, BYTE *pbEncoded,
DWORD *pcbEncoded)
......@@ -1602,7 +1610,7 @@ static BOOL CRYPT_AsnEncodeNumericString(const CERT_NAME_VALUE *value,
}
}
if (!ret && (dwFlags & CRYPT_ENCODE_ALLOC_FLAG))
CryptMemFree(*(BYTE **)pbEncoded);
CRYPT_FreeSpace(pEncodePara, *(BYTE **)pbEncoded);
}
}
return ret;
......@@ -1656,7 +1664,7 @@ static BOOL CRYPT_AsnEncodePrintableString(const CERT_NAME_VALUE *value,
}
}
if (!ret && (dwFlags & CRYPT_ENCODE_ALLOC_FLAG))
CryptMemFree(*(BYTE **)pbEncoded);
CRYPT_FreeSpace(pEncodePara, *(BYTE **)pbEncoded);
}
}
return ret;
......@@ -1703,7 +1711,7 @@ static BOOL CRYPT_AsnEncodeIA5String(const CERT_NAME_VALUE *value,
}
}
if (!ret && (dwFlags & CRYPT_ENCODE_ALLOC_FLAG))
CryptMemFree(*(BYTE **)pbEncoded);
CRYPT_FreeSpace(pEncodePara, *(BYTE **)pbEncoded);
}
}
return ret;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment