mirror of
https://frontier.innolan.net/rainlance/amiga-tz.git
synced 2026-09-12 02:52:15 +00:00
Fix memory leak if ALL_STATE and multithreaded.
* localtime.c (gmtcheck) [ALL_STATE]: Don't leak memory if two threads invoke this function nearly simultaneously. Problem reported by Andy Heninger in: http://mm.icann.org/pipermail/tz/2014-September/021599.html * NEWS: Document this.
This commit is contained in:
@@ -30,6 +30,10 @@ Unreleased, experimental changes
|
||||
An access to uninitalized data has been fixed.
|
||||
(Thanks to Jörg Richter for reporting the problem.)
|
||||
|
||||
A memory leak has been fixed if ALL_STATE and THREAD_SAFE are defined
|
||||
and two threads race to initialize data used by gmtime-like functions.
|
||||
(Thanks to Andy Heninger for reporting the problem.)
|
||||
|
||||
Changes affecting build procedure
|
||||
|
||||
'make check' now checks better for properly-sorted data.
|
||||
|
||||
+6
-4
@@ -1249,12 +1249,14 @@ gmtcheck(void)
|
||||
return;
|
||||
if (lock() != 0)
|
||||
return;
|
||||
if (! gmt_is_set) {
|
||||
#ifdef ALL_STATE
|
||||
gmtptr = malloc(sizeof *gmtptr);
|
||||
gmtptr = malloc(sizeof *gmtptr);
|
||||
#endif
|
||||
if (gmtptr)
|
||||
gmtload(gmtptr);
|
||||
gmt_is_set = true;
|
||||
if (gmtptr)
|
||||
gmtload(gmtptr);
|
||||
gmt_is_set = true;
|
||||
}
|
||||
unlock();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user