diff options
author | jan.nijtmans <nijtmans@users.sourceforge.net> | 2023-05-08 14:19:04 (GMT) |
---|---|---|
committer | jan.nijtmans <nijtmans@users.sourceforge.net> | 2023-05-08 14:19:04 (GMT) |
commit | 8f15f094913d1b1304514e093149538bf2cfedc5 (patch) | |
tree | 958026ef3f62f43e54cc1e8b02e177dd65c2583e | |
parent | 4dcdd51adbe299efe67dc9aa9c2034df855aef28 (diff) | |
parent | 133b43a5217bb5e27bced051732443f474610b9c (diff) | |
download | tcl-8f15f094913d1b1304514e093149538bf2cfedc5.zip tcl-8f15f094913d1b1304514e093149538bf2cfedc5.tar.gz tcl-8f15f094913d1b1304514e093149538bf2cfedc5.tar.bz2 |
Fix [96551aca55]: Avoid pointer arithmetic with NULL in FOREACH_STRUCT(). Some typo's
-rw-r--r-- | generic/tclOOInt.h | 6 | ||||
-rw-r--r-- | tests/ooUtil.test | 6 |
2 files changed, 6 insertions, 6 deletions
diff --git a/generic/tclOOInt.h b/generic/tclOOInt.h index 725c4ce..bbe4102 100644 --- a/generic/tclOOInt.h +++ b/generic/tclOOInt.h @@ -589,12 +589,12 @@ MODULE_SCOPE void TclOOSetupVariableResolver(Tcl_Namespace *nsPtr); /* * A variation where the array is an array of structs. There's no issue with * possible NULLs; every element of the array will be iterated over and the - * varable set to a pointer to each of those elements in turn. - * REQUIRES DECLARATION: int i; + * variable set to a pointer to each of those elements in turn. + * REQUIRES DECLARATION: int i; See [96551aca55] for more FOREACH_STRUCT details. */ #define FOREACH_STRUCT(var,ary) \ - for(i=0 ; var=&((ary).list[i]), i<(ary).num; i++) + if (i=0, (ary).num>0) for(; var=&((ary).list[i]), i<(ary).num; i++) /* * Convenience macros for iterating through hash tables. FOREACH_HASH_DECLS diff --git a/tests/ooUtil.test b/tests/ooUtil.test index c8be9c8..f41c668 100644 --- a/tests/ooUtil.test +++ b/tests/ooUtil.test @@ -429,7 +429,7 @@ test ooUtil-5.1 {TIP 478: abstract} -setup { parent destroy } -result {1 1 1 123 456 ::y} -test ooUtil-6.1 {TIP 478: classvarable} -setup { +test ooUtil-6.1 {TIP 478: classvariable} -setup { oo::class create parent } -body { oo::class create xyz { @@ -459,7 +459,7 @@ test ooUtil-6.1 {TIP 478: classvarable} -setup { } -cleanup { parent destroy } -result {{1 2} {1 2} {2 3}} -test ooUtil-6.2 {TIP 478: classvarable error case} -setup { +test ooUtil-6.2 {TIP 478: classvariable error case} -setup { oo::class create parent } -body { oo::class create xyz { @@ -475,7 +475,7 @@ test ooUtil-6.2 {TIP 478: classvarable error case} -setup { } -returnCodes error -cleanup { parent destroy } -result {bad variable name "x(1)": can't create a scalar variable that looks like an array element} -test ooUtil-6.3 {TIP 478: classvarable error case} -setup { +test ooUtil-6.3 {TIP 478: classvariable error case} -setup { oo::class create parent } -body { oo::class create xyz { |