MDEV-32189 follow-up: Properly initialize UErrorCode for ucal_getDefaultTimeZone()

Initialize UErrorCode to U_ZERO_ERROR before passing it to
ucal_getDefaultTimeZone(), as required by the ICU conventions.

Passing an uninitialized status variable  leads to undefined behavior and
non-deterministic failures.

This issue was not observed on x64 builds, but appeared during
Windows/ARM64 CI testing. The lack of initialization led to
inconsistent fallback between ICU and  native Windows time zone.

mtr tests with restarts showed the alternation of system_time_zone,
as reported by check_testcase after the test.

-SYSTEM_TIME_ZONE	Coordinated Universal Time
+SYSTEM_TIME_ZONE	Etc/UTC
This commit is contained in:
Vladislav Vaintroub
2025-05-21 16:32:23 +02:00
parent 9e1c1d429f
commit 59ee33e14e

View File

@ -159,7 +159,7 @@ extern "C" void my_tzname(char* sys_timezone, size_t size)
{
/* TZ environment variable not set - return default timezone name*/
UChar default_tzname[MAX_TIMEZONE_LEN];
UErrorCode ec;
UErrorCode ec= U_ZERO_ERROR;
int32_t len=
ucal_getDefaultTimeZone(default_tzname, MAX_TIMEZONE_LEN, &ec);
if (U_SUCCESS(ec))