drw.c: Avoid potential memory leak in drw_cur_create()

If drw was NULL, memory was still allocated for cur.
This commit is contained in:
Quentin Rameau 2015-11-18 22:45:26 +01:00 committed by Markus Teich
parent 243c8cf7b6
commit 996a4c5c6e

4
drw.c
View File

@ -396,9 +396,9 @@ drw_font_getexts(Fnt *font, const char *text, unsigned int len, unsigned int *w,
Cur * Cur *
drw_cur_create(Drw *drw, int shape) { drw_cur_create(Drw *drw, int shape) {
Cur *cur = (Cur *)calloc(1, sizeof(Cur)); Cur *cur;
if(!drw || !cur) if(!drw || !(cur = (Cur *)calloc(1, sizeof(Cur))))
return NULL; return NULL;
cur->cursor = XCreateFontCursor(drw->dpy, shape); cur->cursor = XCreateFontCursor(drw->dpy, shape);
return cur; return cur;