diff options
| author | Jay Kwak <82421531+jkwak-work@users.noreply.github.com> | 2025-07-31 13:50:55 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-07-31 20:50:55 +0000 |
| commit | 4a255d211834a5d0218cf1d166180930754b16cd (patch) | |
| tree | e810b87edb4faf95d310b205eee073ca05fe4f56 /source/core/slang-io.cpp | |
| parent | 8e1a6a1b4720eebceb98890b4905f044c7d620de (diff) | |
Fix bug in ci test (#8005)
This commit fixes two problems.
1. uninitialized file handle for lock-file test
2. uninitialized static variable for lock-file test
The first bug is more of speculartive rather than actual bug.
The second bug was causing heap corruption when it was retried, because
the counter was not reset to zero on "retry" and it wrote data to an
invalida range in an array.
Diffstat (limited to 'source/core/slang-io.cpp')
| -rw-r--r-- | source/core/slang-io.cpp | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/source/core/slang-io.cpp b/source/core/slang-io.cpp index 851c70073..0720e788f 100644 --- a/source/core/slang-io.cpp +++ b/source/core/slang-io.cpp @@ -1316,9 +1316,17 @@ void LockFile::close() return; #if SLANG_WINDOWS_FAMILY - ::CloseHandle(m_fileHandle); + if (m_fileHandle != INVALID_HANDLE_VALUE) + { + ::CloseHandle(m_fileHandle); + m_fileHandle = INVALID_HANDLE_VALUE; + } #else - ::close(m_fileHandle); + if (m_fileHandle != -1) + { + ::close(m_fileHandle); + m_fileHandle = -1; + } #endif m_isOpen = false; @@ -1409,6 +1417,11 @@ SlangResult LockFile::unlock() LockFile::LockFile() : m_isOpen(false) { +#if SLANG_WINDOWS_FAMILY + m_fileHandle = INVALID_HANDLE_VALUE; +#else + m_fileHandle = -1; +#endif } LockFile::~LockFile() |
