lib/nbt: Fix a potential memory leak
parent
f0092b78d3
commit
d5ce50a4a9
|
@ -899,10 +899,12 @@ namespace NBT {
|
|||
|
||||
ErrorOrVoid List::setElementPointerAt(uint64_t position, Generic* pointer) {
|
||||
if (this->tags.size() <= position) {
|
||||
delete pointer;
|
||||
return ErrorOrVoid(true, ErrorCodes::OUT_OF_RANGE);
|
||||
}
|
||||
|
||||
if (pointer->getTagType() != this->containedType) {
|
||||
delete pointer;
|
||||
return ErrorOrVoid(true, ErrorCodes::INVALID_TYPE);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue