comparison src/if_python3.c @ 33295:a43861545866 v9.0.1913

patch 9.0.1913: if_python: undefined behaviour for function pointers Commit: https://github.com/vim/vim/commit/2ce070c27acd12ccc614afa4cecf4970a645a4af Author: Yee Cheng Chin <ychin.git@gmail.com> Date: Tue Sep 19 20:30:22 2023 +0200 patch 9.0.1913: if_python: undefined behaviour for function pointers Problem: if_python: undefined behaviour for function pointers Solution: Fix if_python undefined behavior for function pointer casts Identified by clang 17 UBSAN (see #12745). Make sure to cast function pointers with the same signature only. closes: #13122 Signed-off-by: Christian Brabandt <cb@256bit.org> Co-authored-by: Yee Cheng Chin <ychin.git@gmail.com>
author Christian Brabandt <cb@256bit.org>
date Tue, 19 Sep 2023 20:45:05 +0200
parents 6e346800670c
children 924e9cb09df7
comparison
equal deleted inserted replaced
33294:190aa75db4cf 33295:a43861545866
1423 { 1423 {
1424 if (p_pyx == 0) 1424 if (p_pyx == 0)
1425 p_pyx = 3; 1425 p_pyx = 3;
1426 1426
1427 DoPyCommand(script == NULL ? (char *) eap->arg : (char *) script, 1427 DoPyCommand(script == NULL ? (char *) eap->arg : (char *) script,
1428 (rangeinitializer) init_range_cmd, 1428 init_range_cmd,
1429 (runner) run_cmd, 1429 (runner) run_cmd,
1430 (void *) eap); 1430 (void *) eap);
1431 } 1431 }
1432 vim_free(script); 1432 vim_free(script);
1433 } 1433 }
1489 } 1489 }
1490 1490
1491 1491
1492 // Execute the file 1492 // Execute the file
1493 DoPyCommand(buffer, 1493 DoPyCommand(buffer,
1494 (rangeinitializer) init_range_cmd, 1494 init_range_cmd,
1495 (runner) run_cmd, 1495 (runner) run_cmd,
1496 (void *) eap); 1496 (void *) eap);
1497 } 1497 }
1498 1498
1499 void 1499 void
1501 { 1501 {
1502 if (p_pyx == 0) 1502 if (p_pyx == 0)
1503 p_pyx = 3; 1503 p_pyx = 3;
1504 1504
1505 DoPyCommand((char *)eap->arg, 1505 DoPyCommand((char *)eap->arg,
1506 (rangeinitializer)init_range_cmd, 1506 init_range_cmd,
1507 (runner)run_do, 1507 (runner)run_do,
1508 (void *)eap); 1508 (void *)eap);
1509 } 1509 }
1510 1510
1511 /////////////////////////////////////////////////////// 1511 ///////////////////////////////////////////////////////
2051 2051
2052 void 2052 void
2053 do_py3eval(char_u *str, typval_T *rettv) 2053 do_py3eval(char_u *str, typval_T *rettv)
2054 { 2054 {
2055 DoPyCommand((char *) str, 2055 DoPyCommand((char *) str,
2056 (rangeinitializer) init_range_eval, 2056 init_range_eval,
2057 (runner) run_eval, 2057 (runner) run_eval,
2058 (void *) rettv); 2058 (void *) rettv);
2059 if (rettv->v_type == VAR_UNKNOWN) 2059 if (rettv->v_type == VAR_UNKNOWN)
2060 { 2060 {
2061 rettv->v_type = VAR_NUMBER; 2061 rettv->v_type = VAR_NUMBER;