diff options
author | Matthias Schiffer <mschiffer@universe-factory.net> | 2015-02-03 12:18:25 +0100 |
---|---|---|
committer | Matthias Schiffer <mschiffer@universe-factory.net> | 2015-02-03 12:18:25 +0100 |
commit | b3c1a9be2f0c3011ae1249573d04a8bdc72f1e8f (patch) | |
tree | 4bb21e7131346786418337dd365404ae0191b20b /src | |
parent | 1d3db43d2974be14b82ccff4c2c737a6c2dbd2ac (diff) | |
download | MinedMap-b3c1a9be2f0c3011ae1249573d04a8bdc72f1e8f.tar MinedMap-b3c1a9be2f0c3011ae1249573d04a8bdc72f1e8f.zip |
Level: make buffer a member to prevent use-after-free
Diffstat (limited to 'src')
-rw-r--r-- | src/World/Level.cpp | 4 | ||||
-rw-r--r-- | src/World/Level.hpp | 3 |
2 files changed, 4 insertions, 3 deletions
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 <iostream> - namespace MinedMap { namespace World { Level::Level(const char *filename) { - std::vector<uint8_t> buffer = readGZip(filename); + buffer = readGZip(filename); Buffer nbt(buffer.data(), buffer.size()); std::pair<std::string, std::shared_ptr<const NBT::Tag>> 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 <cstdint> +#include <vector> namespace MinedMap { @@ -36,6 +37,8 @@ namespace World { class Level { private: + std::vector<uint8_t> buffer; + std::shared_ptr<const NBT::CompoundTag> root; std::shared_ptr<const NBT::CompoundTag> data; |