Skip to content

Commit

Permalink
AlignedAllocator: throw a rawspeed exception, not std::bad_alloc
Browse files Browse the repository at this point in the history
At least, this is consistent with the preexisting practice.
I'm not sure what we want to be doing in reality,
but at least this unbreaks fuzzing.
  • Loading branch information
LebedevRI committed Feb 14, 2023
1 parent 9150760 commit 4a9c763
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/librawspeed/adt/AlignedAllocator.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
#include "AddressSanitizer.h"
#include "common/Common.h"
#include "common/Memory.h"
#include "common/RawspeedException.h"
#include <cstddef> // for size_t
#include <memory> // for allocator_traits

Expand Down Expand Up @@ -52,7 +53,8 @@ template <class T, int alignment> struct AlignedAllocator {

auto* r = alignedMalloc<T, alignment>(numPaddedBytes);
if (!r)
throw std::bad_alloc();
ThrowRSE("Out of memory while trying to allocate %zu bytes",
numPaddedBytes);
ASan::PoisonMemoryRegion(
reinterpret_cast<const volatile std::byte*>(r + numElts),
numPaddedBytes - numBytes);
Expand Down

0 comments on commit 4a9c763

Please sign in to comment.