libc/time: Update g_lcl_tzname only after the success

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
Change-Id: I0117c5b43bee3affb36d118e0b97f6dd7137080b
This commit is contained in:
Xiang Xiao
2021-06-21 02:45:30 +08:00
committed by xiaoxiang
parent 73285ea7f4
commit b7a8ad8318
+9 -9
View File
@@ -2531,19 +2531,12 @@ void tzset(void)
goto out;
}
g_lcl_isset = strlen(name) < sizeof g_lcl_tzname;
if (g_lcl_isset)
{
strcpy(g_lcl_tzname, name);
}
if (lclptr == NULL)
{
lclptr = lib_malloc(sizeof *lclptr);
if (lclptr == NULL)
{
settzname(); /* all we can do */
goto out;
goto tzname;
}
}
@@ -2564,11 +2557,18 @@ void tzset(void)
if (name[0] == ':' || tzparse(name, lclptr, FALSE) != 0)
{
gmtload(lclptr);
goto tzname;
}
}
settzname();
g_lcl_isset = strlen(name) < sizeof g_lcl_tzname;
if (g_lcl_isset)
{
strcpy(g_lcl_tzname, name);
}
tzname:
settzname();
out:
tz_semgive(&g_lcl_sem);
}