[hackers] [sent] drw.c: Avoid potential memory leak in drw_cur_create() || Quentin Rameau
commit 996a4c5c6e7b98c9f3ef50846f567b5d6a2da932
Author: Quentin Rameau <quinq+hackers_AT_fifth.space>
AuthorDate: Wed Nov 18 22:45:26 2015 +0100
Commit: Markus Teich <markus.teich_AT_stusta.mhn.de>
CommitDate: Wed Nov 18 22:50:07 2015 +0100
drw.c: Avoid potential memory leak in drw_cur_create()
If drw was NULL, memory was still allocated for cur.
diff --git a/drw.c b/drw.c
index a2dfe6c..15797ce 100644
--- a/drw.c
+++ b/drw.c
_AT_@ -396,9 +396,9 @@ drw_font_getexts(Fnt *font, const char *text, unsigned int len, unsigned int *w,
Cur *
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;
cur->cursor = XCreateFontCursor(drw->dpy, shape);
return cur;
Received on Wed Nov 18 2015 - 22:48:56 CET
This archive was generated by hypermail 2.3.0
: Wed Nov 18 2015 - 23:00:12 CET