clock: Add safety check for NULL pointer from localtime() func.

Summary:
localtime() can return NULL when there is an error.
@fix

Reviewers: raster, woohyun, Hermet, JackDanielZ

Subscribers: JackDanielZ

Differential Revision: https://phab.enlightenment.org/D2666
This commit is contained in:
Youngbok Shin 2015-06-15 08:17:32 +03:00 committed by Daniel Zaoui
parent 6f33f4f1d1
commit ed343cbab0
1 changed files with 11 additions and 2 deletions

View File

@ -817,8 +817,17 @@ _timediff_set(Elm_Clock_Data *sd)
tt = (time_t)(timev.tv_sec);
tzset();
tm = localtime(&tt);
sd->timediff = (((sd->hrs - tm->tm_hour) * 60 +
sd->min - tm->tm_min) * 60) + sd->sec - tm->tm_sec;
if (tm)
{
sd->timediff = (((sd->hrs - tm->tm_hour) * 60 +
sd->min - tm->tm_min) * 60) + sd->sec - tm->tm_sec;
}
else
{
ERR("Failed to get local time!");
sd->timediff = 0;
}
}
EOLIAN static void