mirror of
https://github.com/scratchfoundation/bgfx.git
synced 2024-11-24 16:48:18 -05:00
Fixed crash when loading invalid texture.
This commit is contained in:
parent
b5ea61856c
commit
00548b325a
1 changed files with 20 additions and 17 deletions
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue