Level: make buffer a member to prevent use-after-free

This commit is contained in:
Matthias Schiffer 2015-02-03 12:18:25 +01:00
parent 1d3db43d29
commit b3c1a9be2f
2 changed files with 4 additions and 3 deletions

View file

@ -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);

View file

@ -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;