_XimEncodingNegotiation: swap order of arguments to calloc

Avoids build failures with gcc 14.2 when MALLOC_0_RETURNS_NULL is defined:

imDefIm.c: In function ‘_XimEncodingNegotiation’:
imDefIm.c:1739:15: error: ‘memcpy’ offset 8 is out of the bounds [0, 1]
 [-Werror=array-bounds=]
 1739 |         (void)memcpy((char *)&buf_s[2], name_ptr, name_len);
      |               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
Part-of: <https://gitlab.freedesktop.org/xorg/lib/libx11/-/merge_requests/267>
This commit is contained in:
Alan Coopersmith 2024-09-29 10:04:40 -07:00
parent 1f01aafa6d
commit 75c5bdee81

View file

@ -1728,7 +1728,7 @@ _XimEncodingNegotiation(
+ sizeof(CARD16)
+ detail_len;
if (!(buf = Xcalloc(XIM_HEADER_SIZE + len, 1)))
if (!(buf = Xcalloc(1, XIM_HEADER_SIZE + len)))
goto free_detail_ptr;
buf_s = (CARD16 *)&buf[XIM_HEADER_SIZE];