about summary refs log tree commit diff
path: root/Src/loop.c
diff options
context:
space:
mode:
Diffstat (limited to 'Src/loop.c')
-rw-r--r--Src/loop.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/Src/loop.c b/Src/loop.c
index f13c8c4a9..41b2e5627 100644
--- a/Src/loop.c
+++ b/Src/loop.c
@@ -497,7 +497,6 @@ execrepeat(Estate state, UNUSED(int do_exec))
 
     end = state->pc + WC_REPEAT_SKIP(code);
 
-    lastval = 0;
     tmp = ecgetstr(state, EC_DUPTOK, &htok);
     if (htok) {
 	singsub(&tmp);
@@ -506,6 +505,7 @@ execrepeat(Estate state, UNUSED(int do_exec))
     count = mathevali(tmp);
     if (errflag)
 	return 1;
+    lastval = 0; /* used when the repeat count is zero */
     pushheap();
     cmdpush(CS_REPEAT);
     loops++;