[Tcl] Fix std_vector typecheck typemaps

In some cases the typecheck typemap would try to access the first
element of an empty Tcl list.

Fixes https://sourceforge.net/p/swig/bugs/1309/
This commit is contained in:
Olly Betts 2022-02-01 13:08:13 +13:00
commit 6f4adde4b4
2 changed files with 19 additions and 12 deletions

View file

@ -0,0 +1,7 @@
if [ catch { load ./li_std_vector[info sharedlibextension] li_std_vector} err_msg ] {
puts stderr "Could not load shared object:\n$err_msg"
}
# # Regression test for bug fixed in SWIG 4.2.0.
if {[sum []] != 0} { error "bad vector sum" }

View file

@ -168,7 +168,7 @@ namespace std {
else
if (nitems == 0)
$1 = 1;
//check the first value to see if it is of correct type
//check the first value to see if it is of correct type
else if ((SWIG_ConvertPtr(listobjv[0],
(void **) &temp,
$descriptor(T *),0)) != 0)
@ -197,7 +197,7 @@ namespace std {
else
if (nitems == 0)
$1 = 1;
//check the first value to see if it is of correct type
//check the first value to see if it is of correct type
else if ((SWIG_ConvertPtr(listobjv[0],
(void **) &temp,
$descriptor(T *),0)) != 0)
@ -331,11 +331,11 @@ namespace std {
else
if (nitems == 0)
$1 = 1;
//check the first value to see if it is of correct type
if (CONVERT_FROM(interp, listobjv[0], &temp) == TCL_ERROR)
$1 = 0;
else
$1 = 1;
//check the first value to see if it is of correct type
else if (CONVERT_FROM(interp, listobjv[0], &temp) == TCL_ERROR)
$1 = 0;
else
$1 = 1;
}
}
@ -358,11 +358,11 @@ namespace std {
else
if (nitems == 0)
$1 = 1;
//check the first value to see if it is of correct type
if (CONVERT_FROM(interp, listobjv[0], &temp) == TCL_ERROR)
$1 = 0;
else
$1 = 1;
//check the first value to see if it is of correct type
else if (CONVERT_FROM(interp, listobjv[0], &temp) == TCL_ERROR)
$1 = 0;
else
$1 = 1;
}
}