Skip to content

Commit 58242dd

Browse files
authored
Fix Crash When Loading an Invalid Background HDR Image (cyberbotics#6744)
1 parent fdd04d5 commit 58242dd

2 files changed

Lines changed: 6 additions & 0 deletions

File tree

docs/reference/changelog-r2024.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,3 +34,4 @@ Released on December **th, 2023.
3434
- Fixed a bug where Webots would crash if a geometry was inserted into a `Shape` node used a bounding box ([#6691](https://github.com/cyberbotics/webots/pull/6691)).
3535
- Removed the old `wb_supervisor_field_import_sf_node` and `wb_supervisor_field_import_mf_node` functions from the list of editor autocomplete suggestions ([#6701](https://github.com/cyberbotics/webots/pull/6701)).
3636
- Fixed a bug preventing nodes from being inserted into unconnected proto fields ([#6735](https://github.com/cyberbotics/webots/pull/6735)).
37+
- Fixed crash when an invalid HDR image was set as a world background ([#6744](https://github.com/cyberbotics/webots/pull/6744)).

src/webots/nodes/WbBackground.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -540,6 +540,11 @@ bool WbBackground::loadIrradianceTexture(int i) {
540540
float *data = stbi_loadf_from_memory(reinterpret_cast<const unsigned char *>(content.constData()), content.size(),
541541
&mIrradianceWidth, &mIrradianceHeight, &components, 0);
542542

543+
if (data == NULL) {
544+
warn(tr("Failed to load HDR texture '%1': %2.").arg(url).arg(stbi_failure_reason()));
545+
return false;
546+
}
547+
543548
const int rotate = gCoordinateSystemRotate(i);
544549
// FIXME: this texture rotation should be performed by OpenGL or in the shader to get a better performance
545550
if (rotate != 0) {

0 commit comments

Comments
 (0)