From 0145abf1fbbcd6316a430ddf44b98f7c02c61492 Mon Sep 17 00:00:00 2001 From: Pawel Kolodziejski Date: Thu, 13 Jan 2005 20:21:12 +0000 Subject: [PATCH] dont load textures with 0 width/height to prevent alloc 0 sized buffer for tinygl --- lua/lrestore.cpp | 2 +- material.cpp | 7 ++++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/lua/lrestore.cpp b/lua/lrestore.cpp index 2932062f025..12f32468dee 100644 --- a/lua/lrestore.cpp +++ b/lua/lrestore.cpp @@ -375,7 +375,7 @@ void lua_Restore(SaveRestoreFunc restoreFunc) { recreateObj(&tempTask->stack.stack[i]); } - restoreFunc(&tempTask->Cstack.base, sizeof(StkId)); + restoreFunc(&tempTask->Cstack.base, sizeof(StkId)); restoreFunc(&tempTask->Cstack.lua2C, sizeof(StkId)); restoreFunc(&tempTask->Cstack.num, sizeof(int)); diff --git a/material.cpp b/material.cpp index 7022027f6dd..398b19fa4df 100644 --- a/material.cpp +++ b/material.cpp @@ -33,7 +33,8 @@ Material::Material(const char *filename, const char *data, int len, const CMap & _height = READ_LE_UINT32(data + 80 + _numImages * 40); if ((_width == 0) || (_height == 0)) { - warning("bad texture size (%dx%d) for texture %s\n", _width, _height, filename); + warning("skip load texture: bad texture size (%dx%d) for texture %s\n", _width, _height, filename); + return; } data += 100 + _numImages * 40; @@ -42,9 +43,13 @@ Material::Material(const char *filename, const char *data, int len, const CMap & } void Material::select() const { + if ((_width == 0) || (_height == 0)) + return; g_driver->selectMaterial(this); } Material::~Material() { + if ((_width == 0) || (_height == 0)) + return; g_driver->destroyMaterial(this); }