emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: master 242a4b49cb: Minor cleanups to X drag-and-drop code


From: Jashank Jeremy
Subject: Re: master 242a4b49cb: Minor cleanups to X drag-and-drop code
Date: Sun, 22 May 2022 16:56:15 +1000
User-agent: Wanderlust/2.15.9 (Almost Unreal) SEMI-EPG/1.14.7 (Harue) FLIM-LB/1.14.9 (Gojō) APEL-LB/10.8 EasyPG/1.0.0 Emacs/29.0.50 (x86_64-pc-linux-gnu) MULE/6.0 (HANACHIRUSATO)

> diff --git a/src/xterm.c b/src/xterm.c
> index a8745894eb2..a3b7c4ac257 100644
> --- a/src/xterm.c
> +++ b/src/xterm.c
> [...]
> @@ -1977,6 +2012,9 @@ xm_read_drag_receiver_info (struct x_display_info 
> *dpyinfo,
>        rec->byteorder = XM_BYTE_ORDER_CUR_FIRST;
>      }
>
> +  if (data[1] > XM_DRAG_PROTOCOL_VERSION)
> +    rc = 0;
> +
>    if (tmp_data)
>      XFree (tmp_data);

Whilst chasing down the build failure against e465ea816d, I observed
some compiler warnings related to this patch:

    .../emacs/src/src/xterm.c:1994:7: warning: variable 'data' is used 
uninitialized whenever 'if' condition is false [-Wsometimes-uninitialized]
      if (rc)
          ^~
    .../emacs/src/src/xterm.c:2016:7: note: uninitialized use occurs here
      if (data[1] > XM_DRAG_PROTOCOL_VERSION)
          ^~~~
    .../emacs/src/src/xterm.c:1994:3: note: remove the 'if' if its condition is 
always true
      if (rc)
      ^~~~~~~
    .../emacs/src/src/xterm.c:1977:16: note: initialize the variable 'data' to 
silence this warning
      uint8_t *data;
                   ^
                    = NULL

This looks like a plausible issue --- XGetWindowProperty looks to be
fallible, and in the event it fails we're potentially dereferencing an
uninitialised value.  I suspect the check introduced in this commit
should be within the immediately preceding region; however, I do not
know what the implications of such a change would be, and thus won't
concretely suggest one.

    ~jashank

Attachment: pgpsvzntFIEJz.pgp
Description: OpenPGP Digital Signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]