[js/webgpu] resolve codescan alert (#19343)

### Description
resolve codescan alert:
https://github.com/microsoft/onnxruntime/security/code-scanning/17687
This commit is contained in:
Yulong Wang 2024-01-30 21:06:21 -08:00 committed by GitHub
parent d73131cf0f
commit dd1f6ccc45
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -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();