mirror of
https://review.haiku-os.org/haiku
synced 2025-02-22 13:38:56 +01:00
Fix some usages of BStackOrHeapArray.
Validates the buffer with IsValid() before actually using it. Thanks Rene!
This commit is contained in:
parent
43f5f35a80
commit
1fb59be1d1
@ -210,6 +210,11 @@ VirtioSCSIController::ExecuteRequest(scsi_ccb *ccb)
|
||||
uint32 inCount = (isIn ? ccb->sg_count : 0) + 1;
|
||||
uint32 outCount = (isOut ? ccb->sg_count : 0) + 1;
|
||||
BStackOrHeapArray<physical_entry, 16> entries(inCount + outCount);
|
||||
if (!entries.IsValid()) {
|
||||
fRequest->SetStatus(SCSI_REQ_INVALID);
|
||||
fRequest->Finish(false);
|
||||
return B_NO_MEMORY;
|
||||
}
|
||||
fRequest->FillRequest(inCount, outCount, entries);
|
||||
|
||||
{
|
||||
|
@ -638,6 +638,8 @@ send_fragments(ipv6_protocol* protocol, struct net_route* route,
|
||||
return status;
|
||||
|
||||
BStackOrHeapArray<uint8, 128> data(bytesLeft);
|
||||
if (!data.IsValid())
|
||||
return B_NO_MEMORY;
|
||||
status = gBufferModule->read(buffer, headersLength, data, bytesLeft);
|
||||
if (status != B_OK)
|
||||
return status;
|
||||
|
@ -524,6 +524,10 @@ MixerCore::_MixThread()
|
||||
chan_info_list inputChanInfos[MAX_CHANNEL_TYPES];
|
||||
BStackOrHeapArray<chan_info_list, 16> mixChanInfos(fMixBufferChannelCount);
|
||||
// TODO: this does not support changing output channel count
|
||||
if (!mixChanInfos.IsValid()) {
|
||||
ERROR("MixerCore::_MixThread mixChanInfos allocation failed\n");
|
||||
return;
|
||||
}
|
||||
|
||||
fEventTime = timeBase;
|
||||
int64 framePos = 0;
|
||||
|
@ -110,6 +110,8 @@ void
|
||||
VUView::_RenderLoop()
|
||||
{
|
||||
BStackOrHeapArray<rgb_color[2], 64> levels(fLevelCount);
|
||||
if (!levels.IsValid())
|
||||
return;
|
||||
|
||||
for (int32 i = 0; i < fLevelCount; i++) {
|
||||
levels[i][0] = levels[i][1] = back_color;
|
||||
|
@ -539,6 +539,8 @@ BasicTerminalBuffer::Find(const char* _pattern, const TermPos& start,
|
||||
|
||||
// convert pattern to UTF8Char array
|
||||
BStackOrHeapArray<UTF8Char, 64> pattern(patternByteLen);
|
||||
if (!pattern.IsValid())
|
||||
return false;
|
||||
int32 patternLen = 0;
|
||||
while (*_pattern != '\0') {
|
||||
int32 charLen = UTF8Char::ByteCount(*_pattern);
|
||||
|
@ -203,6 +203,8 @@ create_path(const char *path, mode_t mode)
|
||||
return EINVAL;
|
||||
|
||||
BStackOrHeapArray<char, 128> buffer(pathLength + 1);
|
||||
if (!buffer.IsValid())
|
||||
return B_NO_MEMORY;
|
||||
|
||||
while (++i < pathLength) {
|
||||
char *slash = strchr(&path[i], '/');
|
||||
|
Loading…
x
Reference in New Issue
Block a user