diff options
author | fluxgen <fluxgen> | 2006-03-14 20:19:33 (GMT) |
---|---|---|
committer | fluxgen <fluxgen> | 2006-03-14 20:19:33 (GMT) |
commit | 0530d278e7f209a4f911d0a362177c694eb9368b (patch) | |
tree | fc014cc03789ed924a3730ce7b735a543ffb7c18 /src/FbTk | |
parent | ddd2233f5a7f6b3793db733f9517bab2e1c76fa2 (diff) | |
download | fluxbox_lack-0530d278e7f209a4f911d0a362177c694eb9368b.zip fluxbox_lack-0530d278e7f209a4f911d0a362177c694eb9368b.tar.bz2 |
fixed memory leak when XCreateImage fail, thanks php-coder
Diffstat (limited to 'src/FbTk')
-rw-r--r-- | src/FbTk/XFontImp.cc | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/src/FbTk/XFontImp.cc b/src/FbTk/XFontImp.cc index d4d6bd5..2e69308 100644 --- a/src/FbTk/XFontImp.cc +++ b/src/FbTk/XFontImp.cc | |||
@@ -221,7 +221,7 @@ void XFontImp::rotate(float angle) { | |||
221 | boxlen/2 - descent, text, 1); | 221 | boxlen/2 - descent, text, 1); |
222 | 222 | ||
223 | // reserve memory for first XImage | 223 | // reserve memory for first XImage |
224 | vertdata = new unsigned char[vert_len * vert_h]; | 224 | vertdata = (unsigned char *)calloc((unsigned)(vert_len * vert_h), 1); |
225 | 225 | ||
226 | XImage *I1 = XCreateImage(dpy, DefaultVisual(dpy, screen), | 226 | XImage *I1 = XCreateImage(dpy, DefaultVisual(dpy, screen), |
227 | 1, XYBitmap, | 227 | 1, XYBitmap, |
@@ -229,7 +229,11 @@ void XFontImp::rotate(float angle) { | |||
229 | vert_w, vert_h, 8, 0); | 229 | vert_w, vert_h, 8, 0); |
230 | 230 | ||
231 | if (I1 == None) { | 231 | if (I1 == None) { |
232 | cerr<<"RotFont: "<<_FBTKTEXT(Error, CreateXImage, "Cant create XImage", "XCreateImage failed for some reason")<<"."<<endl; | 232 | cerr<<"RotFont: "<<_FBTKTEXT(Error, CreateXImage, |
233 | "Cant create XImage", | ||
234 | "XCreateImage failed for some reason") | ||
235 | <<"."<<endl; | ||
236 | free(vertdata); | ||
233 | delete m_rotfont; | 237 | delete m_rotfont; |
234 | m_rotfont = 0; | 238 | m_rotfont = 0; |
235 | return; | 239 | return; |
@@ -267,7 +271,11 @@ void XFontImp::rotate(float angle) { | |||
267 | (char *)bitdata, bit_w, bit_h, 8, 0); | 271 | (char *)bitdata, bit_w, bit_h, 8, 0); |
268 | 272 | ||
269 | if (I2 == None) { | 273 | if (I2 == None) { |
270 | cerr<<"XFontImp: "<<_FBTKTEXT(Error, CreateXImage, "Cant create XImage", "XCreateImage failed for some reason")<<"."<<endl; | 274 | cerr<<"XFontImp: "<<_FBTKTEXT(Error, CreateXImage, |
275 | "Cant create XImage", | ||
276 | "XCreateImage failed for some reason") | ||
277 | <<"."<<endl; | ||
278 | free(bitdata); | ||
271 | delete m_rotfont; | 279 | delete m_rotfont; |
272 | m_rotfont = 0; | 280 | m_rotfont = 0; |
273 | return; | 281 | return; |