From: Erwin Janssen Date: Sat, 7 Jan 2017 11:51:01 +0000 (+0100) Subject: Fixed use of unitialized variable in lefty X-Git-Tag: 2.42.0~213^2~2^2~15 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=1ef7b1f762ac3147daf2a41f2072687abc6d6945;p=graphviz Fixed use of unitialized variable in lefty In the file cmd/lefty/ws/x11/gquery.c, function Gqwpopaction: THe char c is declared without initializer, giving it a unpredictable value. If the next if statement takes the false branch, the function where c is set is not executed. The next if statement then checks `c != 13`, but because C could have any value, the behavior is unpredictable. Initializing c with a known value, such as 0, fixes the problem. --- diff --git a/cmd/lefty/ws/x11/gquery.c b/cmd/lefty/ws/x11/gquery.c index 485172782..7e42fe3f2 100644 --- a/cmd/lefty/ws/x11/gquery.c +++ b/cmd/lefty/ws/x11/gquery.c @@ -306,7 +306,7 @@ int GQqueryask ( void Gqwpopaction (Widget w, XEvent *evp, char **app, unsigned int *anp) { Gwidget_t *widget; - char c; + char c = 0; if (evp->type == KeyPress || evp->type == KeyRelease) XLookupString ((XKeyEvent *) evp, &c, 1, NULL, NULL);