Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: Loading an invalid image causes a crash #678

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion librtt/Display/Rtt_TextureFactory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,13 @@ TextureFactory::FindOrCreate(
if ( result.IsNull() )
{
PlatformBitmap *bitmap = CreateBitmap( filePath.GetString(), flags, isMask );
result = CreateAndAdd( key, bitmap, true, isRetina );

if ( bitmap )
{
result = CreateAndAdd( key, bitmap, true, isRetina );
} else {
Rtt_ASSERT( result.IsNull() );
}
}

return result;
Expand Down
4 changes: 4 additions & 0 deletions platform/emscripten/Rtt_EmscriptenBitmap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,10 @@ namespace Rtt
{
fFormat = kRGBA;
}
else
{
Rtt_LogException("Failed to load %s\n", path);
}
}
else
if (ext == ".png")
Expand Down
4 changes: 4 additions & 0 deletions platform/linux/src/Rtt_LinuxBitmap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,10 @@ namespace Rtt
{
fFormat = kRGBA;
}
else
{
Rtt_LogException("Failed to load %s\n", path);
}
}
else if (ext == ".png")
{
Expand Down
2 changes: 2 additions & 0 deletions platform/shared/Rtt_BitmapUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,8 @@ namespace bitmapUtil
format = Rtt::PlatformBitmap::Format::kRGBA;
return im;
}

return NULL;
}

//
Expand Down