Skip to content

Commit

Permalink
Fix Crash When Loading an Invalid Background HDR Image (#6744)
Browse files Browse the repository at this point in the history
  • Loading branch information
CoolSpy3 authored Dec 24, 2024
1 parent fdd04d5 commit 58242dd
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
1 change: 1 addition & 0 deletions docs/reference/changelog-r2024.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,4 @@ Released on December **th, 2023.
- 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)).
- 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)).
- Fixed a bug preventing nodes from being inserted into unconnected proto fields ([#6735](https://github.com/cyberbotics/webots/pull/6735)).
- Fixed crash when an invalid HDR image was set as a world background ([#6744](https://github.com/cyberbotics/webots/pull/6744)).
5 changes: 5 additions & 0 deletions src/webots/nodes/WbBackground.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -540,6 +540,11 @@ bool WbBackground::loadIrradianceTexture(int i) {
float *data = stbi_loadf_from_memory(reinterpret_cast<const unsigned char *>(content.constData()), content.size(),
&mIrradianceWidth, &mIrradianceHeight, &components, 0);

if (data == NULL) {
warn(tr("Failed to load HDR texture '%1': %2.").arg(url).arg(stbi_failure_reason()));
return false;
}

const int rotate = gCoordinateSystemRotate(i);
// FIXME: this texture rotation should be performed by OpenGL or in the shader to get a better performance
if (rotate != 0) {
Expand Down

0 comments on commit 58242dd

Please sign in to comment.