fix: V-002 security vulnerability

Automated security fix generated by Orbis Security AI
This commit is contained in:
orbisai0security 2026-04-16 11:21:44 +00:00
parent f63e9f3a80
commit 9da2ad7eba

View file

@ -140,7 +140,12 @@ secp256k1_context* secp256k1_context_preallocated_create(void* prealloc, unsigne
secp256k1_context* secp256k1_context_create(unsigned int flags) { secp256k1_context* secp256k1_context_create(unsigned int flags) {
size_t const prealloc_size = secp256k1_context_preallocated_size(flags); size_t const prealloc_size = secp256k1_context_preallocated_size(flags);
secp256k1_context* ctx = (secp256k1_context*)checked_malloc(&default_error_callback, prealloc_size); secp256k1_context* ctx;
if (prealloc_size == 0) {
return NULL;
}
ctx = (secp256k1_context*)checked_malloc(&default_error_callback, prealloc_size);
if (EXPECT(secp256k1_context_preallocated_create(ctx, flags) == NULL, 0)) { if (EXPECT(secp256k1_context_preallocated_create(ctx, flags) == NULL, 0)) {
free(ctx); free(ctx);
return NULL; return NULL;