hermet pushed a commit to branch master.

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

commit dd592451b8a65cb1a444691a88cef1d3fcc19fb2
Author: ChunEon Park <her...@hermet.pe.kr>
Date:   Mon Jun 15 13:39:14 2015 +0900

    clendar: + null check
    
    gmtime can return NULL vaule.
    if so strftime will cause crash.
    
    this patch just prevent that potential situation.
---
 src/lib/elm_calendar.c | 24 +++++++++++++++---------
 1 file changed, 15 insertions(+), 9 deletions(-)

diff --git a/src/lib/elm_calendar.c b/src/lib/elm_calendar.c
index 0fc78f3..90a6f17 100644
--- a/src/lib/elm_calendar.c
+++ b/src/lib/elm_calendar.c
@@ -1004,17 +1004,23 @@ _elm_calendar_evas_object_smart_add(Eo *obj, 
Elm_Calendar_Data *priv)
         /* FIXME: I'm not aware of a known max, so if it fails,
          * just make it larger. :| */
         char buf[20];
+        struct tm *info;
+
         /* I don't know of a better way of doing it */
-        if (strftime(buf, sizeof(buf), "%a", gmtime(&weekday)))
+        info = gmtime(&weekday);
+        if (info)
           {
-             priv->weekdays[i] = eina_stringshare_add(buf);
-          }
-        else
-          {
-             /* If we failed getting day, get a default value */
-             priv->weekdays[i] = _days_abbrev[i];
-             WRN("Failed getting weekday name for '%s' from locale.",
-                 _days_abbrev[i]);
+             if (strftime(buf, sizeof(buf), "%a", info))
+               {
+                  priv->weekdays[i] = eina_stringshare_add(buf);
+               }
+             else
+               {
+                  /* If we failed getting day, get a default value */
+                  priv->weekdays[i] = _days_abbrev[i];
+                  WRN("Failed getting weekday name for '%s' from locale.",
+                      _days_abbrev[i]);
+               }
           }
         weekday += 86400; /* Advance by a day */
      }

-- 


Reply via email to