Commit: 6651d3659fb198fad3e229430f4127933f44e3e1
Parent: 8033e2eeb9d2f810f0e763df9fb601b1d968ad48
Author: Hiltjo Posthuma
Date: Fri, 3 Nov 2017 15:31:37 +0100
fix a possible free of a uninitialize variable in paste()
Diffstat:
1 file changed, 9 insertions(+), 6 deletions(-)
diff --git a/pinentry-dmenu.c b/pinentry-dmenu.c
@@ -551,17 +551,20 @@ keypress(XKeyEvent *ev) {
}
static void
-paste(void) {
+paste(void)
+{
char *p, *q;
int di;
unsigned long dl;
Atom da;
- /* We have been given the current selection, now insert it into input */
- XGetWindowProperty(dpy, win, utf8, 0, pin_len / 4, False, utf8, &da, &di,
- &dl, &dl, (unsigned char **)&p);
- insert(p, (q = strchr(p, '\n')) ? q - p : (ssize_t) strlen(p));
- XFree(p);
+ /* we have been given the current selection, now insert it into input */
+ if (XGetWindowProperty(dpy, win, utf8, 0, (pin_len/ 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);
+ }
drawwin();
}