From b3c1a9be2f0c3011ae1249573d04a8bdc72f1e8f Mon Sep 17 00:00:00 2001 From: Matthias Schiffer Date: Tue, 3 Feb 2015 12:18:25 +0100 Subject: Level: make buffer a member to prevent use-after-free --- src/World/Level.cpp | 4 +--- src/World/Level.hpp | 3 +++ 2 files changed, 4 insertions(+), 3 deletions(-) (limited to 'src/World') diff --git a/src/World/Level.cpp b/src/World/Level.cpp index 8cd396e..56628b9 100644 --- a/src/World/Level.cpp +++ b/src/World/Level.cpp @@ -29,14 +29,12 @@ #include "../Util.hpp" #include "../NBT/IntTag.hpp" -#include - namespace MinedMap { namespace World { Level::Level(const char *filename) { - std::vector buffer = readGZip(filename); + buffer = readGZip(filename); Buffer nbt(buffer.data(), buffer.size()); std::pair> tag = NBT::Tag::readNamedTag(&nbt); diff --git a/src/World/Level.hpp b/src/World/Level.hpp index 6cdfc4e..6fd45a8 100644 --- a/src/World/Level.hpp +++ b/src/World/Level.hpp @@ -29,6 +29,7 @@ #include "../NBT/CompoundTag.hpp" #include +#include namespace MinedMap { @@ -36,6 +37,8 @@ namespace World { class Level { private: + std::vector buffer; + std::shared_ptr root; std::shared_ptr data; -- cgit v1.2.3