mirror of
https://github.com/overte-org/overte.git
synced 2025-08-04 07:03:41 +02:00
Fail in Packet::create if size is invalid
This commit is contained in:
parent
e1fc242967
commit
f90f3a05be
2 changed files with 3 additions and 5 deletions
|
@ -14,7 +14,6 @@
|
|||
|
||||
#include <iostream>
|
||||
|
||||
|
||||
#include <CoverageMap.h>
|
||||
#include <NodeData.h>
|
||||
#include <OctreeConstants.h>
|
||||
|
|
|
@ -29,10 +29,9 @@ std::unique_ptr<Packet> Packet::create(PacketType::Value type, qint64 size) {
|
|||
// default size of -1, means biggest packet possible
|
||||
size = maxPayload;
|
||||
}
|
||||
if (size <= 0 || size > maxPayload) {
|
||||
// Invalid size, return null pointer
|
||||
return std::unique_ptr<Packet>();
|
||||
}
|
||||
|
||||
// Fail with invalid size
|
||||
Q_ASSERT(size >= 0 || size < maxPayload);
|
||||
|
||||
// allocate memory
|
||||
return std::unique_ptr<Packet>(new Packet(type, size));
|
||||
|
|
Loading…
Reference in a new issue