[hackers] [dmenu] fix a possible free of a uninitialize variable in paste() || Hiltjo Posthuma
commit 1cabeda5505dcc35d4d2ca2a09151a7c449fb401
Author: Hiltjo Posthuma <hiltjo_AT_codemadness.org>
AuthorDate: Fri Nov 3 15:31:37 2017 +0100
Commit: Hiltjo Posthuma <hiltjo_AT_codemadness.org>
CommitDate: Fri Nov 3 21:07:02 2017 +0100
fix a possible free of a uninitialize variable in paste()
diff --git a/dmenu.c b/dmenu.c
index 91330f1..eae5685 100644
--- a/dmenu.c
+++ b/dmenu.c
_AT_@ -467,10 +467,12 @@ paste(void)
Atom da;
/* we have been given the current selection, now insert it into input */
- XGetWindowProperty(dpy, win, utf8, 0, (sizeof text / 4) + 1, False,
- utf8, &da, &di, &dl, &dl, (unsigned char **)&p);
- insert(p, (q = strchr(p, '\n')) ? q - p : (ssize_t)strlen(p));
- XFree(p);
+ if (XGetWindowProperty(dpy, win, utf8, 0, (sizeof text / 4) + 1, False,
+ utf8, &da, &di, &dl, &dl, (unsigned char **)&p)
+ == Success && p) {
+ insert(p, (q = strchr(p, '\n')) ? q - p : (ssize_t)strlen(p));
+ XFree(p);
+ }
drawmenu();
}
Received on Fri Nov 03 2017 - 21:07:43 CET
This archive was generated by hypermail 2.3.0
: Fri Nov 03 2017 - 21:12:24 CET