Browse Source

DeepClone initial memory on Reset

When resetting the computer, deep clone the _initialMemory value to
prevent passing by reference.
ApisNecros 1 year ago
parent
commit
2a18ce4704
1 changed files with 1 additions and 1 deletions
  1. 1 1
      IntComp/Computer.js

+ 1 - 1
IntComp/Computer.js

@@ -514,7 +514,7 @@ module.exports = class Computer {
      * @returns {void}
      */
     Reset() {
-        this.stack = new Stack(this._initialMemory);
+        this.stack = new Stack(DeepClone(this._initialMemory));
         this.outputValues = [];
         this.options.inputModeMap = DeepClone(this.options._initialInputModeMap);
         this.running = false;