]> git.eshelyaron.com Git - emacs.git/commitdiff
Fix byte-swapping of Motif DND tables
authorPo Lu <luangruo@yahoo.com>
Thu, 16 Jun 2022 07:26:55 +0000 (15:26 +0800)
committerPo Lu <luangruo@yahoo.com>
Thu, 16 Jun 2022 07:30:21 +0000 (15:30 +0800)
* src/xterm.c (xm_read_targets_table_rec): Swap nitems first
before checking the length.

src/xterm.c

index 04e3223478f6219638fc5e98f2b91e01304a583f..45c96c51060ca76068fd45fb2a46a9f65d8c51c5 100644 (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;