Fixed crash when loading invalid texture.

This commit is contained in:
Branimir Karadžić 2015-05-27 21:18:43 -07:00
parent b5ea61856c
commit 00548b325a

View file

@ -176,24 +176,27 @@ bgfx::TextureHandle loadTexture(bx::FileReaderI* _reader, const char* _name, uin
BX_FREE(allocator, data);
handle = bgfx::createTexture2D(uint16_t(width), uint16_t(height), 1
, bgfx::TextureFormat::RGBA8
, _flags
, bgfx::copy(img, width*height*4)
);
free(img);
if (NULL != _info)
if (NULL != img)
{
bgfx::calcTextureSize(*_info
, uint16_t(width)
, uint16_t(height)
, 0
, false
, 1
, bgfx::TextureFormat::RGBA8
);
handle = bgfx::createTexture2D(uint16_t(width), uint16_t(height), 1
, bgfx::TextureFormat::RGBA8
, _flags
, bgfx::copy(img, width*height*4)
);
free(img);
if (NULL != _info)
{
bgfx::calcTextureSize(*_info
, uint16_t(width)
, uint16_t(height)
, 0
, false
, 1
, bgfx::TextureFormat::RGBA8
);
}
}
}
else