[libgit2-glib] signature: be safe against a possible NULL date time



commit 2d17b3b9d84886a4401aed942be2e31d444e87e0
Author: Ignacio Casal Quinteiro <icq gnome org>
Date:   Sat Feb 13 15:42:55 2016 +0100

    signature: be safe against a possible NULL date time

 libgit2-glib/ggit-signature.c |   15 ++++++++++-----
 1 files changed, 10 insertions(+), 5 deletions(-)
---
diff --git a/libgit2-glib/ggit-signature.c b/libgit2-glib/ggit-signature.c
index 6027d81..fd3360e 100644
--- a/libgit2-glib/ggit-signature.c
+++ b/libgit2-glib/ggit-signature.c
@@ -332,17 +332,22 @@ ggit_signature_get_time (GgitSignature *signature)
 {
        git_signature *s;
        GDateTime *utc;
-       GTimeZone *tz;
-       GDateTime *ret;
+       GDateTime *ret = NULL;
 
        g_return_val_if_fail (GGIT_IS_SIGNATURE (signature), NULL);
 
        s = _ggit_native_get (signature);
 
        utc = g_date_time_new_from_unix_utc (s->when.time);
-       tz = ggit_signature_get_time_zone (signature);
-       ret = g_date_time_to_timezone (utc, tz);
-       g_date_time_unref (utc);
+
+       if (utc != NULL)
+       {
+               GTimeZone *tz;
+
+               tz = ggit_signature_get_time_zone (signature);
+               ret = g_date_time_to_timezone (utc, tz);
+               g_date_time_unref (utc);
+       }
 
        return ret;
 }


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]