Add missing check for a null surface from image::get_image()
Fixes a NULL pointer dereference when drawing preview pane overlays in the Recall Unit dialog for a unit whose overlays list includes an image that doesn't exist or can't be read, and debug mode is not enabled. This didn't happen in debug mode because image::get_image() retrieves a valid placeholder surface (currently images/misc/missing-image.png) in that situation with debug mode enabled. Reported by SkyOne in the forums: http://r.wesnoth.org/t39983 Thanks to mattsc for pinpointing the commit at fault. Note: the code handling overlays on the listbox/menu of the Recall Unit dialog shouldn't be affected by this since it uses the BLIT image path function instead of accessing surfaces directly.
This commit is contained in:
parent
3890c429fc
commit
0f1e3fab3e
2 changed files with 7 additions and 0 deletions
|
@ -55,6 +55,9 @@ Version 1.11.8+dev:
|
|||
the game to crash (bug #21351).
|
||||
* Changed: Added -Wextra-semi to pedantic compilation.
|
||||
* Changed: Added -Wconditional-uninitialized to pedantic compilation.
|
||||
* Fixed NULL pointer dereference when viewing units in the Recall Unit
|
||||
dialog including nonexistent/unreadable images in their overlays, while
|
||||
not in debug mode.
|
||||
|
||||
Version 1.11.8:
|
||||
* Add-ons client:
|
||||
|
|
|
@ -1121,6 +1121,10 @@ void unit_preview_pane::draw_contents()
|
|||
BOOST_FOREACH(const std::string& overlay, det.overlays) {
|
||||
surface os = image::get_image(overlay);
|
||||
|
||||
if(!os) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if(os->w > rect.w || os->h > rect.h) {
|
||||
os = scale_surface(os, rect.w, rect.h, false);
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue