From dd6b449657d17a8e4a276a8a86f5fb706192d825 Mon Sep 17 00:00:00 2001 From: Yulong Wang <7679871+fs-eire@users.noreply.github.com> Date: Tue, 30 Jan 2024 21:06:21 -0800 Subject: [PATCH] [js/webgpu] resolve codescan alert (#19343) ### Description resolve codescan alert: https://github.com/microsoft/onnxruntime/security/code-scanning/17687 --- js/web/lib/wasm/jsep/backend-webgpu.ts | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/js/web/lib/wasm/jsep/backend-webgpu.ts b/js/web/lib/wasm/jsep/backend-webgpu.ts index 58efa795dba48..4b544595d76bb 100644 --- a/js/web/lib/wasm/jsep/backend-webgpu.ts +++ b/js/web/lib/wasm/jsep/backend-webgpu.ts @@ -705,13 +705,11 @@ export class WebGpuBackend { captureBegin(): void { LOG_DEBUG('info', 'captureBegin'); - let sessionCommandList = this.capturedCommandList.get(this.currentSessionId!); - let sessionPendingKernels = this.capturedPendingKernels.get(this.currentSessionId!); - if (!sessionCommandList) { - sessionCommandList = []; - this.capturedCommandList.set(this.currentSessionId!, sessionCommandList); - sessionPendingKernels = []; - this.capturedPendingKernels.set(this.currentSessionId!, sessionPendingKernels); + if (!this.capturedCommandList.get(this.currentSessionId!)) { + this.capturedCommandList.set(this.currentSessionId!, []); + } + if (!this.capturedPendingKernels.get(this.currentSessionId!)) { + this.capturedPendingKernels.set(this.currentSessionId!, []); } // flush the left commands before we change the status. this.flush();