From 597e4731f9178d9e9141049f832adbe0a68eedf9 Mon Sep 17 00:00:00 2001 From: Simon Tatham Date: Fri, 9 Apr 2021 17:52:49 +0100 Subject: [PATCH] winctrls: fix warning about uninitialised variable. Coverity points out that it's theoretically possible for the main loop in radioline_common() to read r.bottom without having gone through the conditional setup at the start of the function _or_ a previous iteration of the main loop. I think this can only happen in some silly case that doesn't actually come up, but on the other hand, it's easy to add the necessary robustness. --- windows/winctrls.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/windows/winctrls.c b/windows/winctrls.c index 2922d434..c5f43e36 100644 --- a/windows/winctrls.c +++ b/windows/winctrls.c @@ -222,13 +222,15 @@ static void radioline_common(struct ctlpos *cp, char *text, int id, int i; int j; + r.left = GAPBETWEEN; + r.top = cp->ypos; if (text) { - r.left = GAPBETWEEN; - r.top = cp->ypos; r.right = cp->width; r.bottom = STATICHEIGHT; cp->ypos += r.bottom + GAPWITHIN; doctl(cp, r, "STATIC", WS_CHILD | WS_VISIBLE, 0, text, id); + } else { + r.right = r.bottom = 0; } group = WS_GROUP;