aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorSebastian Valle <s.v.h21@hotmail.com>2013-10-01 16:27:57 -0500
committerSebastian Valle <s.v.h21@hotmail.com>2013-10-01 16:27:57 -0500
commit8fb1f7cc97bdb92999309597c5e7259099bf5ce4 (patch)
treecc4f1a7fa8a98a6f4af54a519ebfa80d6a90dd22 /src
parenta8611de906816bfea66a948ac599fb0db69df7f8 (diff)
Tools/MeshExtractor: Implemented 7ca6f56a065a666fc605d2fa402a2eea14bc40c0 in MeshExtractor and fixed a memory leak.
Diffstat (limited to 'src')
-rw-r--r--src/tools/mesh_extractor/MPQ.h3
-rw-r--r--src/tools/mesh_extractor/MPQManager.cpp1
2 files changed, 3 insertions, 1 deletions
diff --git a/src/tools/mesh_extractor/MPQ.h b/src/tools/mesh_extractor/MPQ.h
index 2f8b082f526..30e11741550 100644
--- a/src/tools/mesh_extractor/MPQ.h
+++ b/src/tools/mesh_extractor/MPQ.h
@@ -26,7 +26,8 @@ public:
libmpq__off_t size, transferred;
libmpq__file_unpacked_size(mpq_a, filenum, &size);
- char *buffer = new char[size];
+ char* buffer = new char[size + 1];
+ buffer[size] = '\0';
libmpq__file_read(mpq_a, filenum, (unsigned char*)buffer, size, &transferred);
diff --git a/src/tools/mesh_extractor/MPQManager.cpp b/src/tools/mesh_extractor/MPQManager.cpp
index facd96a28f0..4d3ab808a2e 100644
--- a/src/tools/mesh_extractor/MPQManager.cpp
+++ b/src/tools/mesh_extractor/MPQManager.cpp
@@ -110,5 +110,6 @@ FILE* MPQManager::GetFileFrom(const std::string& path, MPQArchive* file )
}
fwrite(buffer, sizeof(uint8), size, ret);
fseek(ret, 0, SEEK_SET);
+ delete[] buffer;
return ret;
}