SHA256
1
0
forked from pool/libical
libical/libical-0.46-fix-race.patch

94 lines
2.1 KiB
Diff

Index: trunk/libical/src/libical/icaltimezone.c
===================================================================
--- trunk/libical/src/libical/icaltimezone.c (revision 1038)
+++ trunk/libical/src/libical/icaltimezone.c (revision 1039)
@@ -45,6 +45,11 @@
#include <sys/stat.h>
+#ifdef HAVE_PTHREAD
+#include <pthread.h>
+static pthread_mutex_t builtin_mutex = PTHREAD_MUTEX_INITIALIZER;
+#endif
+
#ifdef WIN32
#include <mbstring.h>
#include <windows.h>
@@ -453,8 +458,7 @@
int changes_end_year;
- if (!zone->component)
- icaltimezone_load_builtin_timezone (zone);
+ icaltimezone_load_builtin_timezone (zone);
if (icaltimezone_minimum_expansion_year == -1) {
struct icaltimetype today = icaltime_today();
@@ -1140,8 +1144,7 @@
if (!zone)
return NULL;
- if (!zone->tzid)
- icaltimezone_load_builtin_timezone (zone);
+ icaltimezone_load_builtin_timezone (zone);
return zone->tzid;
}
@@ -1167,8 +1170,7 @@
if (!zone)
return NULL;
- if (!zone->component)
- icaltimezone_load_builtin_timezone (zone);
+ icaltimezone_load_builtin_timezone (zone);
return zone->tznames;
}
@@ -1210,8 +1212,7 @@
if (!zone)
return NULL;
- if (!zone->component)
- icaltimezone_load_builtin_timezone (zone);
+ icaltimezone_load_builtin_timezone (zone);
return zone->component;
}
@@ -1449,8 +1450,7 @@
for (i=0; i<count; i++) {
int z_offset;
zone = icalarray_element_at (builtin_timezones, i);
- if (!zone->component)
- icaltimezone_load_builtin_timezone (zone);
+ icaltimezone_load_builtin_timezone (zone);
z_offset = get_offset(zone);
@@ -1745,6 +1745,12 @@
if (!zone->location || !zone->location[0])
return;
+#ifdef HAVE_PTHREAD
+ pthread_mutex_lock(&builtin_mutex);
+ if (zone->component)
+ goto out;
+#endif
+
#ifdef USE_BUILTIN_TZDATA
{
char *filename;
@@ -1801,8 +1807,11 @@
icalcomponent_remove_component(comp,subcomp);
icalcomponent_free(comp);
}
-#endif
-
+#endif
+#ifdef HAVE_PTHREAD
+ out:
+ pthread_mutex_unlock(&builtin_mutex);
+#endif
}