소스 검색

DeepClone initial memory on Reset

When resetting the computer, deep clone the _initialMemory value to
prevent passing by reference.
ApisNecros 1 년 전
부모
커밋
2a18ce4704
1개의 변경된 파일1개의 추가작업 그리고 1개의 파일을 삭제
  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;