]> git.ipfire.org Git - thirdparty/zstd.git/commit
🔧 Fix memory leak in pthread init functions on failure 4486/head
authorRyan Lefkowitz <rlefkowitz1800@yahoo.com>
Mon, 15 Sep 2025 22:20:01 +0000 (18:20 -0400)
committerRyan Lefkowitz <rlefkowitz1800@yahoo.com>
Mon, 15 Sep 2025 22:20:01 +0000 (18:20 -0400)
commitc59812e558dd6ba24f592c77662204b721bb1dbb
treeca73c67f17f8cea132541e9cf3830613c29cf5d1
parent98d2b90e82e5188968368d952ad6b371772e78e5
🔧 Fix memory leak in pthread init functions on failure

When pthread_mutex_init() or pthread_cond_init() fails in the debug
implementation (DEBUGLEVEL >= 1), the previously allocated memory was
not freed, causing a memory leak.

This fix ensures that allocated memory is properly freed when pthread
initialization functions fail, preventing resource leaks in error
conditions.

The issue affects:
- ZSTD_pthread_mutex_init() at lib/common/threading.c:146
- ZSTD_pthread_cond_init() at lib/common/threading.c:167

This is particularly important for long-running applications or
scenarios with resource constraints where pthread initialization
might fail due to system limits.
lib/common/threading.c