Skip to content

Commit 6fff0e0

Browse files
committed
compat: fix basename buffer to be thread-local on Windows
Add `__declspec(thread)` to the static buffer in the Windows `basename` func to prevent data races in multi-threaded contexts, where concurrent calls could corrupt a shared static buffer. [__declspec(thread)](https://learn.microsoft.com/en-us/cpp/cpp/thread?view=msvc-170) Signed-off-by: slabbancz <slabbancz@microsoft.com>
1 parent acad02a commit 6fff0e0

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

include/fluent-bit/flb_compat.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ static inline char* basename(const char *path)
109109
char dir[_MAX_DIR];
110110
char fname[_MAX_FNAME];
111111
char ext[_MAX_EXT];
112-
static char buf[_MAX_PATH];
112+
static __declspec(thread) char buf[_MAX_PATH];
113113

114114
_splitpath_s(path, drive, _MAX_DRIVE, dir, _MAX_DIR,
115115
fname, _MAX_FNAME, ext, _MAX_EXT);

0 commit comments

Comments
 (0)