Avoid leaking memory when realloc fails

In ossl_property_merge() we can drop the realloc because it just makes
the allocation smaller.

In quic-hq-interop.c we check the realloc result.

Reviewed-by: Kurt Roeckx <kurt@roeckx.be>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/26244)
This commit is contained in:
Frederik Wedel-Heinen 2024-12-22 13:35:00 +01:00 committed by Tomas Mraz
parent 40c55b5aa4
commit 65db21935a
2 changed files with 3 additions and 2 deletions

View File

@ -567,8 +567,7 @@ OSSL_PROPERTY_LIST *ossl_property_merge(const OSSL_PROPERTY_LIST *a,
r->has_optional |= copy->optional;
}
r->num_properties = n;
if (n != t)
r = OPENSSL_realloc(r, sizeof(*r) + (n - 1) * sizeof(r->properties[0]));
return r;
}

View File

@ -911,6 +911,8 @@ int main(int argc, char *argv[])
while (req != NULL) {
total_requests++;
req_array = OPENSSL_realloc(req_array, sizeof(char *) * total_requests);
if (req_array == NULL)
goto end;
req_array[total_requests - 1] = req;
req = strtok(NULL, " ");
}