Skip to content

Commit

Permalink
GLTF Loader: better validate input parameters of the PrepareGLTFTextu…
Browse files Browse the repository at this point in the history
…reInitData function
  • Loading branch information
TheMostDiligent committed Jul 31, 2023
1 parent 9349a50 commit 87f78ff
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions AssetLoader/src/GLTFLoader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -427,8 +427,17 @@ RefCntAutoPtr<TextureInitData> PrepareGLTFTextureInitData(
Uint32 NumMipLevels,
int SizeAlignment = -1)
{
VERIFY_EXPR(_Image.pData != nullptr);
VERIFY_EXPR(_Image.Width > 0 && _Image.Height > 0 && _Image.NumComponents > 0);
if (_Image.pData == nullptr)
{
UNEXPECTED("Image data is null");
return {};
}

if (_Image.Width <= 0 || _Image.Height <= 0 || _Image.NumComponents <= 0 || _Image.ComponentSize <= 0)
{
UNEXPECTED("Invalid image attributes. Size: ", _Image.Width, "x", _Image.Height, ", num components: ", _Image.NumComponents, ", component size: ", _Image.ComponentSize);
return {};
}

const auto TexFormat = GetModelImageDataTextureFormat(_Image);
const auto& FmtAttribs = GetTextureFormatAttribs(TexFormat);
Expand Down

0 comments on commit 87f78ff

Please sign in to comment.