mirror of
https://github.com/neocturne/MinedMap.git
synced 2025-03-05 01:24:53 +01:00
Level: make buffer a member to prevent use-after-free
This commit is contained in:
parent
1d3db43d29
commit
b3c1a9be2f
2 changed files with 4 additions and 3 deletions
|
@ -29,14 +29,12 @@
|
||||||
#include "../Util.hpp"
|
#include "../Util.hpp"
|
||||||
#include "../NBT/IntTag.hpp"
|
#include "../NBT/IntTag.hpp"
|
||||||
|
|
||||||
#include <iostream>
|
|
||||||
|
|
||||||
|
|
||||||
namespace MinedMap {
|
namespace MinedMap {
|
||||||
namespace World {
|
namespace World {
|
||||||
|
|
||||||
Level::Level(const char *filename) {
|
Level::Level(const char *filename) {
|
||||||
std::vector<uint8_t> buffer = readGZip(filename);
|
buffer = readGZip(filename);
|
||||||
|
|
||||||
Buffer nbt(buffer.data(), buffer.size());
|
Buffer nbt(buffer.data(), buffer.size());
|
||||||
std::pair<std::string, std::shared_ptr<const NBT::Tag>> tag = NBT::Tag::readNamedTag(&nbt);
|
std::pair<std::string, std::shared_ptr<const NBT::Tag>> tag = NBT::Tag::readNamedTag(&nbt);
|
||||||
|
|
|
@ -29,6 +29,7 @@
|
||||||
#include "../NBT/CompoundTag.hpp"
|
#include "../NBT/CompoundTag.hpp"
|
||||||
|
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
|
|
||||||
namespace MinedMap {
|
namespace MinedMap {
|
||||||
|
@ -36,6 +37,8 @@ namespace World {
|
||||||
|
|
||||||
class Level {
|
class Level {
|
||||||
private:
|
private:
|
||||||
|
std::vector<uint8_t> buffer;
|
||||||
|
|
||||||
std::shared_ptr<const NBT::CompoundTag> root;
|
std::shared_ptr<const NBT::CompoundTag> root;
|
||||||
std::shared_ptr<const NBT::CompoundTag> data;
|
std::shared_ptr<const NBT::CompoundTag> data;
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue