fix a possible free of a uninitialize variable in paste() 1cabeda5
Hiltjo Posthuma · 2017-11-03 15:31 1 file(s) · +6 −4
dmenu.c +6 −4
467 467
	Atom da;
468 468
469 469
	/* we have been given the current selection, now insert it into input */
470 -
	XGetWindowProperty(dpy, win, utf8, 0, (sizeof text / 4) + 1, False,
471 -
	                   utf8, &da, &di, &dl, &dl, (unsigned char **)&p);
472 -
	insert(p, (q = strchr(p, '\n')) ? q - p : (ssize_t)strlen(p));
473 -
	XFree(p);
470 +
	if (XGetWindowProperty(dpy, win, utf8, 0, (sizeof text / 4) + 1, False,
471 +
	                   utf8, &da, &di, &dl, &dl, (unsigned char **)&p)
472 +
	    == Success && p) {
473 +
		insert(p, (q = strchr(p, '\n')) ? q - p : (ssize_t)strlen(p));
474 +
		XFree(p);
475 +
	}
474 476
	drawmenu();
475 477
}
476 478