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 <ofourdan@redhat.com>
Fixes: commit 3c07a01c4 - xwayland: Use xdg-output name for XRandR
This commit is contained in:
Olivier Fourdan 2023-03-07 10:53:16 +01:00 committed by Olivier Fourdan
parent 4e20d96e8d
commit 1209a1bb57

View File

@ -815,7 +815,7 @@ xwl_output_create(struct xwl_screen *xwl_screen, uint32_t id,
Bool with_xrandr, uint32_t version) Bool with_xrandr, uint32_t version)
{ {
struct xwl_output *xwl_output; struct xwl_output *xwl_output;
char name[MAX_OUTPUT_NAME]; char name[MAX_OUTPUT_NAME] = { '\0', };
xwl_output = calloc(1, sizeof *xwl_output); xwl_output = calloc(1, sizeof *xwl_output);
if (xwl_output == NULL) { if (xwl_output == NULL) {