VideoCommon: when loading a PNG with no custom texture data levels already, create a level, this avoids a potential segfault

This commit is contained in:
iwubcode
2023-06-02 22:02:37 -05:00
parent d03e09c8fd
commit 47c40d51df
3 changed files with 5 additions and 8 deletions

View File

@ -72,8 +72,11 @@ CustomAssetLibrary::LoadInfo DirectFilesystemAssetLibrary::LoadTexture(const Ass
}
else if (ext == ".png")
{
LoadPNGTexture(data, asset_path.string());
if (data->m_levels.empty()) [[unlikely]]
// If we have no levels, create one to pass into LoadPNGTexture
if (data->m_levels.empty())
data->m_levels.push_back({});
if (!LoadPNGTexture(&data->m_levels[0], asset_path.string()))
return {};
if (!LoadMips(asset_path, data))
return {};