mirror of
https://github.com/fergalmoran/ladybird.git
synced 2026-01-06 08:36:15 +00:00
LibCrypto: Remove all uses of VLAs
This removes all uses of VLAs with either Vectors with inline capacity for the expected soft upper bound, or the occasional heap allocation.
This commit is contained in:
committed by
Andreas Kling
parent
0d50d3ed1e
commit
b05beb79d4
@@ -273,9 +273,10 @@ UnsignedBigInteger random_number(const UnsignedBigInteger& min, const UnsignedBi
|
||||
UnsignedBigInteger base;
|
||||
auto size = range.trimmed_length() * sizeof(u32) + 2;
|
||||
// "+2" is intentional (see below).
|
||||
// Also, if we're about to crash anyway, at least produce a nice error:
|
||||
VERIFY(size < 8 * MiB);
|
||||
u8 buf[size];
|
||||
ByteBuffer buffer;
|
||||
buffer.grow(size);
|
||||
auto* buf = buffer.data();
|
||||
|
||||
fill_with_random(buf, size);
|
||||
UnsignedBigInteger random { buf, size };
|
||||
// At this point, `random` is a large number, in the range [0, 256^size).
|
||||
|
||||
Reference in New Issue
Block a user