jackdanielz pushed a commit to branch master.

http://git.enlightenment.org/core/elementary.git/commit/?id=7291772fabd7cfa76bbc0c414177d43d1541de00

commit 7291772fabd7cfa76bbc0c414177d43d1541de00
Author: Youngbok Shin <youngb.s...@samsung.com>
Date:   Mon Jun 15 08:17:32 2015 +0300

    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
---
 src/lib/elm_clock.c | 13 +++++++++++--
 1 file changed, 11 insertions(+), 2 deletions(-)

diff --git a/src/lib/elm_clock.c b/src/lib/elm_clock.c
index 30765b9..4195e83 100644
--- a/src/lib/elm_clock.c
+++ b/src/lib/elm_clock.c
@@ -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

-- 


Reply via email to