mirror of
https://github.com/BinomialLLC/basis_universal.git
synced 2026-10-28 19:55:30 +00:00
containers: increase_capacity() returns false before asserting when nofail_flag is set
try_resize()/try_reserve() etc. (nofail) are used to fail cleanly on huge allocations, e.g. the Wuffs LDR loader's pixel and work buffers for a small crafted file whose header claims a big image. In Debug the assert(0) fired before the nofail check, so such a file aborted Debug builds instead of failing the load. Callers without nofail are unchanged (assert, then abort). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
a14c492262
commit
73b648c704
@@ -47,10 +47,10 @@ namespace basisu
|
||||
// Basic sanity check min_new_capacity
|
||||
if (!can_fit_into_size_t((uint64_t)min_new_capacity * element_size))
|
||||
{
|
||||
assert(0);
|
||||
|
||||
if (nofail_flag)
|
||||
return false;
|
||||
|
||||
assert(0);
|
||||
|
||||
container_abort("elemental_vector::increase_capacity: requesting too many elements\n");
|
||||
}
|
||||
@@ -79,11 +79,11 @@ namespace basisu
|
||||
|
||||
if (!can_fit_into_size_t(new_capacity_u64))
|
||||
{
|
||||
assert(0);
|
||||
|
||||
if (nofail_flag)
|
||||
return false;
|
||||
|
||||
assert(0);
|
||||
|
||||
container_abort("elemental_vector::increase_capacity: vector too large\n");
|
||||
}
|
||||
}
|
||||
@@ -92,11 +92,11 @@ namespace basisu
|
||||
|
||||
if (!can_fit_into_size_t(desired_size_u64))
|
||||
{
|
||||
assert(0);
|
||||
|
||||
if (nofail_flag)
|
||||
return false;
|
||||
|
||||
assert(0);
|
||||
|
||||
container_abort("elemental_vector::increase_capacity: vector too large\n");
|
||||
}
|
||||
|
||||
@@ -111,11 +111,11 @@ namespace basisu
|
||||
if (!new_p)
|
||||
{
|
||||
fprintf(stderr, "elemental_vector::increase_capacity: Allocation failed!\n");
|
||||
assert(0);
|
||||
|
||||
if (nofail_flag)
|
||||
return false;
|
||||
|
||||
assert(0);
|
||||
|
||||
container_abort("elemental_vector::increase_capacity: realloc() failed allocating %zu bytes", desired_size);
|
||||
}
|
||||
|
||||
@@ -136,11 +136,11 @@ namespace basisu
|
||||
if (!new_p)
|
||||
{
|
||||
fprintf(stderr, "elemental_vector::increase_capacity: Allocation failed!\n");
|
||||
assert(0);
|
||||
|
||||
if (nofail_flag)
|
||||
return false;
|
||||
|
||||
assert(0);
|
||||
|
||||
container_abort("elemental_vector::increase_capacity: malloc() failed allocating %zu bytes", desired_size);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user