mirror of
https://github.com/openssl/openssl.git
synced 2025-01-18 13:44:20 +08:00
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:
parent
40c55b5aa4
commit
65db21935a
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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, " ");
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user