Browse Source

Merge branch 'fix_loop_counter' of https://github.com/sec65/CyberChef

n1474335 3 years ago
parent
commit
2f53ee3974
2 changed files with 5 additions and 0 deletions
  1. 4 0
      src/core/operations/ConditionalJump.mjs
  2. 1 0
      src/core/operations/Jump.mjs

+ 4 - 0
src/core/operations/ConditionalJump.mjs

@@ -64,6 +64,7 @@ class ConditionalJump extends Operation {
             jmpIndex = getLabelIndex(label, state);
             jmpIndex = getLabelIndex(label, state);
 
 
         if (state.numJumps >= maxJumps || jmpIndex === -1) {
         if (state.numJumps >= maxJumps || jmpIndex === -1) {
+            state.numJumps = 0;
             return state;
             return state;
         }
         }
 
 
@@ -74,6 +75,9 @@ class ConditionalJump extends Operation {
                 state.progress = jmpIndex;
                 state.progress = jmpIndex;
                 state.numJumps++;
                 state.numJumps++;
             }
             }
+            else {
+                state.numJumps = 0;
+            }
         }
         }
 
 
         return state;
         return state;

+ 1 - 0
src/core/operations/Jump.mjs

@@ -52,6 +52,7 @@ class Jump extends Operation {
         const jmpIndex = getLabelIndex(label, state);
         const jmpIndex = getLabelIndex(label, state);
 
 
         if (state.numJumps >= maxJumps || jmpIndex === -1) {
         if (state.numJumps >= maxJumps || jmpIndex === -1) {
+            state.numJumps = 0;
             return state;
             return state;
         }
         }