1
0
Fork 0
mirror of https://github.com/juce-framework/JUCE.git synced 2026-01-09 23:34:20 +00:00

AudioSampleBuffer: Fix a potential nullptr dereference flagged by clang-tidy

This commit is contained in:
reuk 2025-04-08 20:01:11 +01:00
parent 7fc75c35f9
commit 63c6187fdf
No known key found for this signature in database

View file

@ -1167,6 +1167,15 @@ private:
allocatedBytes = (size_t) numChannels * (size_t) size * sizeof (Type) + channelListSize + 32;
allocatedData.malloc (allocatedBytes);
if (allocatedData.get() == nullptr)
{
// Allocation failure!
jassertfalse;
allocatedBytes = 0;
return;
}
channels = unalignedPointerCast<Type**> (allocatedData.get());
auto chan = unalignedPointerCast<Type*> (allocatedData + channelListSize);
@ -1237,7 +1246,7 @@ private:
int numChannels = 0, size = 0;
size_t allocatedBytes = 0;
Type** channels;
Type** channels = nullptr;
HeapBlock<char, true> allocatedData;
Type* preallocatedChannelSpace[32];
bool isClear = false;