Tcl Source Code

Check-in [3481934110]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Fix Coverity CID 1251203: break vs continue in for-step clause
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | Coverity CID 1251203
Files: files | file ages | folders
SHA1: 3481934110127541f5e95055fa92c3b4aefbc102
User & Date: dkf 2015-08-01 19:37:04
Context
2015-08-02
12:22
Fix more problems with break and continue in for-step clauses. check-in: 7a737d57dd user: dkf tags: Coverity CID 1251203
2015-08-01
19:37
Fix Coverity CID 1251203: break vs continue in for-step clause check-in: 3481934110 user: dkf tags: Coverity CID 1251203
19:00
explicitly ignore Tcl_PushCallFrame and TclPushStackFrame return value - it is always TCL_OK. Incons... check-in: 7448dc7ef9 user: msofer tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to generic/tclCompile.c.

4097
4098
4099
4100
4101
4102
4103
4104
4105
4106
4107
4108
4109
4110
4111
	    &auxContinuePtr);
    if (rangePtr == NULL || rangePtr->type != LOOP_EXCEPTION_RANGE) {
	auxContinuePtr = NULL;
    } else if (auxContinuePtr->stackDepth == envPtr->currStackDepth-wordCount
	    && auxContinuePtr->expandTarget == envPtr->expandCount-expandCount) {
	auxContinuePtr = NULL;
    } else {
	continueRange = auxBreakPtr - envPtr->exceptAuxArrayPtr;
    }

    if (auxBreakPtr != NULL || auxContinuePtr != NULL) {
	loopRange = TclCreateExceptRange(LOOP_EXCEPTION_RANGE, envPtr);
	ExceptionRangeStarts(envPtr, loopRange);
    }








|







4097
4098
4099
4100
4101
4102
4103
4104
4105
4106
4107
4108
4109
4110
4111
	    &auxContinuePtr);
    if (rangePtr == NULL || rangePtr->type != LOOP_EXCEPTION_RANGE) {
	auxContinuePtr = NULL;
    } else if (auxContinuePtr->stackDepth == envPtr->currStackDepth-wordCount
	    && auxContinuePtr->expandTarget == envPtr->expandCount-expandCount) {
	auxContinuePtr = NULL;
    } else {
	continueRange = auxContinuePtr - envPtr->exceptAuxArrayPtr;
    }

    if (auxBreakPtr != NULL || auxContinuePtr != NULL) {
	loopRange = TclCreateExceptRange(LOOP_EXCEPTION_RANGE, envPtr);
	ExceptionRangeStarts(envPtr, loopRange);
    }

Changes to tests/for.test.

1180
1181
1182
1183
1184
1185
1186








































1187
1188
1189
1190
1191
1192
1193
	    }]
	    set tmp $end
	    set end [meminfo]
	}
	expr {$end - $tmp}
    }} {return -level 0 -code continue}
} 0









































# cleanup
::tcltest::cleanupTests
return

# Local Variables:
# mode: tcl







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
	    }]
	    set tmp $end
	    set end [meminfo]
	}
	expr {$end - $tmp}
    }} {return -level 0 -code continue}
} 0

test for-8.0 {Coverity CID 1251203: break vs continue in for-step clause} {
    apply {{} {
	for {set k 0} {$k < 3} {incr k} {
	    set j 0
	    list a [\
	    for {set i 0} {$i < 5} {incr i; list a [eval {}]} {
		incr j
	    }]
	    incr i
	}
	list $i $j $k
    }}
} {6 5 3}
test for-8.1 {Coverity CID 1251203: break vs continue in for-step clause} {
    apply {{} {
	for {set k 0} {$k < 3} {incr k} {
	    set j 0
	    list a [\
	    for {set i 0} {$i < 5} {incr i;list a [eval break]} {
		incr j
	    }]
	    incr i
	}
	list $i $j $k
    }}
} {2 1 3}
test for-8.2 {Coverity CID 1251203: break vs continue in for-step clause} {
    apply {{} {
	for {set k 0} {$k < 3} {incr k} {
	    set j 0
	    list a [\
	    for {set i 0} {$i < 5} {incr i;list a [eval continue]} {
		incr j
	    }]
	    incr i
	}
	list $i $j $k
    }}
} {1 1 3}

# cleanup
::tcltest::cleanupTests
return

# Local Variables:
# mode: tcl