Commit 8b8b43d5 authored by Rémi Bernon's avatar Rémi Bernon Committed by Alexandre Julliard

crypt32: Grow item size buffer by more than 1 at a time.

When Steam starts and connects, it sometimes does some crypt32 processing and ends up spending a huge amount of time in ntdll memcpy, reallocating buffers, effectively getting stuck while connecting to the user account. Signed-off-by: 's avatarRémi Bernon <rbernon@codeweavers.com> Signed-off-by: 's avatarAlexandre Julliard <julliard@winehq.org>
parent 0c36633a
......@@ -628,7 +628,7 @@ static BOOL CRYPT_AsnDecodeArray(const struct AsnArrayDescriptor *arrayDesc,
if ((ret = CRYPT_GetLengthIndefinite(pbEncoded, cbEncoded, &dataLen)))
{
DWORD bytesNeeded = arrayDesc->minArraySize, cItems = 0, decoded;
DWORD bytesNeeded = arrayDesc->minArraySize, cItems = 0, capacity = 0, decoded;
BYTE lenBytes = GET_LEN_BYTES(pbEncoded[1]);
/* There can be arbitrarily many items, but there is often only one.
*/
......@@ -687,17 +687,18 @@ static BOOL CRYPT_AsnDecodeArray(const struct AsnArrayDescriptor *arrayDesc,
continue;
}
cItems++;
if (itemSizes != &itemSize)
itemSizes = CryptMemRealloc(itemSizes,
cItems * sizeof(struct AsnArrayItemSize));
else if (cItems > 1)
if (++cItems <= 1)
itemSizes = &itemSize;
else if (itemSizes == &itemSize)
{
itemSizes =
CryptMemAlloc(
cItems * sizeof(struct AsnArrayItemSize));
if (itemSizes)
*itemSizes = itemSize;
capacity = 1024;
itemSizes = CryptMemAlloc(capacity * sizeof(struct AsnArrayItemSize));
if (itemSizes) *itemSizes = itemSize;
}
else if (cItems > capacity)
{
capacity = capacity * 3 / 2;
itemSizes = CryptMemRealloc(itemSizes, capacity * sizeof(struct AsnArrayItemSize));
}
if (itemSizes)
{
......
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