]> granicus.if.org Git - vim/commitdiff
patch 9.0.1042: ASAN gives false alarm about array access. v9.0.1042
authorBram Moolenaar <Bram@vim.org>
Fri, 9 Dec 2022 22:49:23 +0000 (22:49 +0000)
committerBram Moolenaar <Bram@vim.org>
Fri, 9 Dec 2022 22:49:23 +0000 (22:49 +0000)
Problem:    ASAN gives false alarm about array access.
Solution:   Use an intermediate pointer.

src/version.c
src/vim9class.c

index 10d93134102b35b8993f7a99329bcbed7d004f22..14b6d2868a2c7da56ec6edcf4dcece857ad685c5 100644 (file)
@@ -695,6 +695,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    1042,
 /**/
     1041,
 /**/
index 395d83a1207f02a7e004e7be2a40682d367a8132..8f2f09f3b5ad736f250a1e48d98a6b57f38ec7de 100644 (file)
@@ -441,7 +441,10 @@ class_object_index(
        for (int i = 0; i < cl->class_obj_method_count; ++i)
        {
            ufunc_T *fp = cl->class_obj_methods[i];
-           if (STRNCMP(name, fp->uf_name, len) == 0 && fp->uf_name[len] == NUL)
+           // Use a separate pointer to avoid that ASAN complains about
+           // uf_name[] only being 4 characters.
+           char_u *ufname = (char_u *)fp->uf_name;
+           if (STRNCMP(name, ufname, len) == 0 && ufname[len] == NUL)
            {
                typval_T    argvars[MAX_FUNC_ARGS + 1];
                int         argcount = 0;