gettextprop: check result of XGetTextProperty (undefined behaviour for XFree)
This commit is contained in:
		
							
								
								
									
										3
									
								
								dwm.c
									
									
									
									
									
								
							
							
						
						
									
										3
									
								
								dwm.c
									
									
									
									
									
								
							| @@ -910,8 +910,7 @@ gettextprop(Window w, Atom atom, char *text, unsigned int size) | ||||
| 	if (!text || size == 0) | ||||
| 		return 0; | ||||
| 	text[0] = '\0'; | ||||
| 	XGetTextProperty(dpy, w, &name, atom); | ||||
| 	if (!name.nitems) | ||||
| 	if (!XGetTextProperty(dpy, w, &name, atom) || !name.nitems) | ||||
| 		return 0; | ||||
| 	if (name.encoding == XA_STRING) | ||||
| 		strncpy(text, (char *)name.value, size - 1); | ||||
|   | ||||
		Reference in New Issue
	
	Block a user