Fix byte-swapping of Motif DND tables

* src/xterm.c (xm_read_targets_table_rec): Swap nitems first
before checking the length.
This commit is contained in:
Po Lu 2022-06-16 15:26:55 +08:00
parent 61bdad4685
commit b2b939e5a1

View file

@ -1663,12 +1663,12 @@ xm_read_targets_table_rec (uint8_t *bytes, ptrdiff_t length,
nitems = *(uint16_t *) bytes;
if (length < 2 + nitems * 4)
return NULL;
if (byteorder != XM_BYTE_ORDER_CUR_FIRST)
SWAPCARD16 (nitems);
if (length < 2 + nitems * 4)
return NULL;
rec = xmalloc (FLEXSIZEOF (struct xm_targets_table_rec,
targets, nitems * 4));
rec->n_targets = nitems;