BMessage: Fix declared variable-length array has negative size
Add checks for value of 'size', since FlattenedSize() may return negative value (B_NO_INIT). Pointed out by Clang Static Analyzer. Change-Id: I68176ee47076512a0b96539f9986ac5edbb587af Reviewed-on: https://review.haiku-os.org/c/haiku/+/3772 Reviewed-by: Adrien Destugues <pulkomandy@gmail.com>
This commit is contained in:
parent
06a78d0d88
commit
e459857d1c
@ -3241,6 +3241,9 @@ BMessage::ReplaceMessage(const char* name, int32 index, const BMessage* message)
|
||||
return B_BAD_VALUE;
|
||||
|
||||
ssize_t size = message->FlattenedSize();
|
||||
if (size < 0)
|
||||
return B_BAD_VALUE;
|
||||
|
||||
char buffer[size];
|
||||
|
||||
status_t error = message->Flatten(buffer, size);
|
||||
@ -3266,6 +3269,9 @@ BMessage::ReplaceFlat(const char* name, int32 index, BFlattenable* object)
|
||||
return B_BAD_VALUE;
|
||||
|
||||
ssize_t size = object->FlattenedSize();
|
||||
if (size < 0)
|
||||
return B_BAD_VALUE;
|
||||
|
||||
char buffer[size];
|
||||
|
||||
status_t error = object->Flatten(buffer, size);
|
||||
|
Loading…
Reference in New Issue
Block a user