Fix a bug in TextureUtil, may help #9248

This commit is contained in:
Henrik Rydgard 2017-01-28 23:16:37 +01:00
parent e59cafe177
commit acef9af5d4
2 changed files with 8 additions and 6 deletions

View File

@ -79,13 +79,12 @@ static bool LoadTextureLevels(const uint8_t *data, size_t size, ImageFileType ty
bool ManagedTexture::LoadFromFileData(const uint8_t *data, size_t dataSize, ImageFileType type) {
using namespace Draw;
int width[16], height[16];
uint8_t *image[16] = { nullptr };
int width[16]{}, height[16]{};
uint8_t *image[16]{};
int num_levels;
int zim_flags;
int num_levels = 0;
int zim_flags = 0;
DataFormat fmt;
if (!LoadTextureLevels(data, dataSize, type, width, height, &num_levels, &fmt, image, &zim_flags)) {
return false;
}
@ -95,8 +94,10 @@ bool ManagedTexture::LoadFromFileData(const uint8_t *data, size_t dataSize, Imag
num_levels = 1;
}
if (texture_)
if (texture_) {
delete texture_;
texture_ = nullptr;
}
TextureDesc desc{};
desc.type = TextureType::LINEAR2D;

View File

@ -21,6 +21,7 @@ public:
}
void GLLost() override {
delete texture_;
texture_ = nullptr;
}
void GLRestore() override {
if (!filename_.empty()) {