Skip to content

Commit ad5c71a

Browse files
committed
Fix gmtime handling and add platform defines
Add platform-specific defines for gmtime variants in BUILD.gn (HAVE_GMTIME_R on Linux/ChromeOS/Android/mac/iOS, HAVE_GMTIME_S on Windows). Update cmsplugin.c::_cmsGetTime to guard against gmtime returning NULL: copy the result into ptr_time only if non-NULL and return a boolean success value, avoiding a NULL dereference inside the critical section.
1 parent 0267271 commit ad5c71a

2 files changed

Lines changed: 9 additions & 0 deletions

File tree

third_party/BUILD.gn

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -306,6 +306,12 @@ source_set("fx_lcms2") {
306306
"lcms/src/cmswtpnt.c",
307307
"lcms/src/cmsxform.c",
308308
]
309+
if (is_linux || is_chromeos || is_android || is_mac || is_ios) {
310+
defines = [ "HAVE_GMTIME_R" ]
311+
}
312+
if (is_win) {
313+
defines = [ "HAVE_GMTIME_S" ]
314+
}
309315
deps = [ "../core/fxcrt" ]
310316
}
311317

third_party/lcms/src/cmsplugin.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1057,7 +1057,10 @@ cmsBool _cmsGetTime(struct tm* ptr_time)
10571057

10581058
_cmsEnterCriticalSectionPrimitive(&_cmsContextPoolHeadMutex);
10591059
t = gmtime(&now);
1060+
if (t != NULL)
1061+
*ptr_time = *t;
10601062
_cmsLeaveCriticalSectionPrimitive(&_cmsContextPoolHeadMutex);
1063+
return t != NULL;
10611064
#endif
10621065

10631066
if (t == NULL)

0 commit comments

Comments
 (0)