]> git.ipfire.org Git - thirdparty/vim.git/commitdiff
patch 9.2.0337: list indexing broken on big-endian 32-bit platforms v9.2.0337
authorJames McCoy <jamessan@jamessan.com>
Sat, 11 Apr 2026 15:00:50 +0000 (15:00 +0000)
committerChristian Brabandt <cb@256bit.org>
Sat, 11 Apr 2026 15:04:00 +0000 (15:04 +0000)
Problem:  check_range_index_one() expects a long * but n1 is a
          varnumber_T. Casting varnumber_T * to long * is undefined
          behaviour and reads the wrong bytes on big-endian platforms
          (John Paul Adrian Glaubitz)
Solution: Use a local long variable and pass that pointer to
          check_range_index_one() (James McCoy)

fixes:  #19798
closes: #19952

Signed-off-by: James McCoy <jamessan@jamessan.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
src/list.c
src/version.c

index c9e9d686bdb91f47b2aa055cd24a8afc4529865b..3074bb93f2ed5992a1593aba96a04999dd00c5c1 100644 (file)
@@ -1368,7 +1368,8 @@ list_slice_or_index(
     {
        // copy the item to "var1" to avoid that freeing the list makes it
        // invalid.
-       listitem_T *li = check_range_index_one(list, (long *)&n1, TRUE, TRUE);
+       long index = n1;
+       listitem_T *li = check_range_index_one(list, &index, TRUE, TRUE);
        if (li == NULL)
            return FAIL;
        copy_tv(&li->li_tv, &var1);
index 0b3a06d204d3a3f0765042cb6f23fc19bc28f5b6..f4e5ef7ec273b10c1ca84245a4379bbc3355ce70 100644 (file)
@@ -734,6 +734,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    337,
 /**/
     336,
 /**/