Skip to content

Commit

Permalink
fixup! Free memory when realloc fails in ossl_property_merge() and ch…
Browse files Browse the repository at this point in the history
…eck realloc result in demo code.
  • Loading branch information
fwh-dc committed Dec 25, 2024
1 parent 3857af2 commit b6877a5
Showing 1 changed file with 2 additions and 7 deletions.
9 changes: 2 additions & 7 deletions crypto/property/property_parse.c
Original file line number Diff line number Diff line change
Expand Up @@ -541,7 +541,7 @@ OSSL_PROPERTY_LIST *ossl_property_merge(const OSSL_PROPERTY_LIST *a,
const OSSL_PROPERTY_DEFINITION *const ap = a->properties;
const OSSL_PROPERTY_DEFINITION *const bp = b->properties;
const OSSL_PROPERTY_DEFINITION *copy;
OSSL_PROPERTY_LIST *r, *rtmp;
OSSL_PROPERTY_LIST *r;
int i, j, n;
const int t = a->num_properties + b->num_properties;

Expand All @@ -567,12 +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) {
rtmp = OPENSSL_realloc(r, sizeof(*r) + (n - 1) * sizeof(r->properties[0]));
if (rtmp == NULL)
OPENSSL_free(r);
r = rtmp;
}

return r;
}

Expand Down

0 comments on commit b6877a5

Please sign in to comment.