mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-01-10 08:09:26 +01:00
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:
parent
d03e09c8fd
commit
47c40d51df
@ -515,11 +515,6 @@ bool LoadDDSTexture(CustomTextureData::Level* level, const std::string& filename
|
|||||||
info.first_mip_row_length, info.first_mip_size);
|
info.first_mip_row_length, info.first_mip_size);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool LoadPNGTexture(CustomTextureData* texture, const std::string& filename)
|
|
||||||
{
|
|
||||||
return LoadPNGTexture(&texture->m_levels[0], filename);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool LoadPNGTexture(CustomTextureData::Level* level, const std::string& filename)
|
bool LoadPNGTexture(CustomTextureData::Level* level, const std::string& filename)
|
||||||
{
|
{
|
||||||
if (!level) [[unlikely]]
|
if (!level) [[unlikely]]
|
||||||
|
@ -27,6 +27,5 @@ public:
|
|||||||
|
|
||||||
bool LoadDDSTexture(CustomTextureData* texture, const std::string& filename);
|
bool LoadDDSTexture(CustomTextureData* texture, const std::string& filename);
|
||||||
bool LoadDDSTexture(CustomTextureData::Level* level, const std::string& filename, u32 mip_level);
|
bool LoadDDSTexture(CustomTextureData::Level* level, const std::string& filename, u32 mip_level);
|
||||||
bool LoadPNGTexture(CustomTextureData* texture, const std::string& filename);
|
|
||||||
bool LoadPNGTexture(CustomTextureData::Level* level, const std::string& filename);
|
bool LoadPNGTexture(CustomTextureData::Level* level, const std::string& filename);
|
||||||
} // namespace VideoCommon
|
} // namespace VideoCommon
|
||||||
|
@ -72,8 +72,11 @@ CustomAssetLibrary::LoadInfo DirectFilesystemAssetLibrary::LoadTexture(const Ass
|
|||||||
}
|
}
|
||||||
else if (ext == ".png")
|
else if (ext == ".png")
|
||||||
{
|
{
|
||||||
LoadPNGTexture(data, asset_path.string());
|
// If we have no levels, create one to pass into LoadPNGTexture
|
||||||
if (data->m_levels.empty()) [[unlikely]]
|
if (data->m_levels.empty())
|
||||||
|
data->m_levels.push_back({});
|
||||||
|
|
||||||
|
if (!LoadPNGTexture(&data->m_levels[0], asset_path.string()))
|
||||||
return {};
|
return {};
|
||||||
if (!LoadMips(asset_path, data))
|
if (!LoadMips(asset_path, data))
|
||||||
return {};
|
return {};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user