From 1209a1bb57628df108600b09a77b15104e1bf1e2 Mon Sep 17 00:00:00 2001 From: Olivier Fourdan Date: Tue, 7 Mar 2023 10:53:16 +0100 Subject: [PATCH] xwayland: Fix uninitialised value created by a stack allocation Commit 3c07a01c4 (xwayland: Use xdg-output name for XRandR) changed the logic to use a fixed sized buffer allocated on the stack to pass to RROutputCreate() which would then copy it. Valgrind complains about this: == Conditional jump or move depends on uninitialised value(s) == at 0x49954B: MakeAtom (atom.c:87) == by 0x5108B3: RRMonitorCrtcName (rrmonitor.c:33) == by 0x510BBB: RRMonitorSetFromServer (rrmonitor.c:92) == by 0x511882: RRMonitorMakeList (rrmonitor.c:373) == by 0x512175: ProcRRGetMonitors (rrmonitor.c:634) == by 0x508091: ProcRRDispatch (randr.c:748) == by 0x4A860E: Dispatch (dispatch.c:546) == by 0x4B692F: dix_main (main.c:271) == by 0x431C90: main (stubmain.c:34) == Uninitialised value was created by a stack allocation == at 0x42122C: xwl_output_create (xwayland-output.c:816) This is actually harmless, but also simple to avoid by just initializing the content of the array with zeros, so let's just fix that. Signed-off-by: Olivier Fourdan Fixes: commit 3c07a01c4 - xwayland: Use xdg-output name for XRandR --- hw/xwayland/xwayland-output.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hw/xwayland/xwayland-output.c b/hw/xwayland/xwayland-output.c index afc416560..661e1828d 100644 --- a/hw/xwayland/xwayland-output.c +++ b/hw/xwayland/xwayland-output.c @@ -815,7 +815,7 @@ xwl_output_create(struct xwl_screen *xwl_screen, uint32_t id, Bool with_xrandr, uint32_t version) { struct xwl_output *xwl_output; - char name[MAX_OUTPUT_NAME]; + char name[MAX_OUTPUT_NAME] = { '\0', }; xwl_output = calloc(1, sizeof *xwl_output); if (xwl_output == NULL) {