mirror of
https://github.com/janet-lang/janet
synced 2025-01-26 23:24:44 +00:00
Fix infinite loop in some cases.
Problem - reusing a tainted variable without reinitializing.
This commit is contained in:
parent
92df01b99d
commit
7a84fc4742
@ -622,6 +622,7 @@ static JanetSlot janetc_while(JanetFopts opts, int32_t argn, const Janet *argv)
|
|||||||
/* Check if closure created in while scope. If so,
|
/* Check if closure created in while scope. If so,
|
||||||
* recompile in a function scope. */
|
* recompile in a function scope. */
|
||||||
if (tempscope.flags & JANET_SCOPE_CLOSURE) {
|
if (tempscope.flags & JANET_SCOPE_CLOSURE) {
|
||||||
|
subopts = janetc_fopts_default(c);
|
||||||
tempscope.flags |= JANET_SCOPE_UNUSED;
|
tempscope.flags |= JANET_SCOPE_UNUSED;
|
||||||
janetc_popscope(c);
|
janetc_popscope(c);
|
||||||
janet_v__cnt(c->buffer) = labelwt;
|
janet_v__cnt(c->buffer) = labelwt;
|
||||||
|
@ -281,4 +281,8 @@ neldb\0\0\0\xD8\x05printG\x01\0\xDE\xDE\xDE'\x03\0marshal_tes/\x02
|
|||||||
(assert (= nil (peg/match peg2 "1:a2:bb:5:cccccc")) "lenprefix 6")
|
(assert (= nil (peg/match peg2 "1:a2:bb:5:cccccc")) "lenprefix 6")
|
||||||
(assert (= nil (peg/match peg2 "1:a2:bb:7:cccccc")) "lenprefix 7")
|
(assert (= nil (peg/match peg2 "1:a2:bb:7:cccccc")) "lenprefix 7")
|
||||||
|
|
||||||
|
# Regression #400
|
||||||
|
(assert (= nil (while (and false false) (fn []) (error "should not happen"))) "strangeloop 1")
|
||||||
|
(assert (= nil (while (not= nil nil) (fn []) (error "should not happen"))) "strangeloop 2")
|
||||||
|
|
||||||
(end-suite)
|
(end-suite)
|
||||||
|
Loading…
Reference in New Issue
Block a user