Fix bug: 'src_image' might be NULL if width||height are 0 (#3188223)

With ROT90-SystemTray fluxbox crashed. It is a bit unclear of where
to catch pixmaps / windows with either width or height equal to 0; IMHO
this needs more investigation.
This commit is contained in:
Mathias Gumz 2011-02-21 19:21:38 +01:00
parent ccb5ef6624
commit 341b2f43e5

View file

@ -218,14 +218,21 @@ void FbPixmap::rotate(FbTk::Orientation orient) {
unsigned int neww = oldw, newh = oldh;
translateSize(orient, neww, newh);
// reverse height/width for new pixmap
FbPixmap new_pm(drawable(), neww, newh, depth());
// width|height could be 0. this happens (for example) if
// the systemtray-tool is ROT90. in that case 'src_image'
// becomes NULL and caused a SIGSEV upon XDestroyImage()
// TODO: catch dimensions with '0' earlier?
//
// make an image copy
XImage *src_image = XGetImage(display(), drawable(),
0, 0, // pos
oldw, oldh, // size
~0, // plane mask
ZPixmap); // format
// reverse height/width for new pixmap
FbPixmap new_pm(drawable(), neww, newh, depth());
if (src_image) {
GContext gc(drawable());
@ -273,6 +280,8 @@ void FbPixmap::rotate(FbTk::Orientation orient) {
}
XDestroyImage(src_image);
}
// free old pixmap and set new from new_pm
free();