From d5ce50a4a9edf4c6adf6289978d3ec3a62ef7bfd Mon Sep 17 00:00:00 2001 From: BodgeMaster <> Date: Sun, 9 Oct 2022 10:18:20 +0200 Subject: [PATCH] lib/nbt: Fix a potential memory leak --- src/lib/nbt.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/lib/nbt.cpp b/src/lib/nbt.cpp index 455d185..054d036 100644 --- a/src/lib/nbt.cpp +++ b/src/lib/nbt.cpp @@ -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); }