[folks] tracker: Fix crash on handling invalid birthday dates from contacts



commit 48f5e7094cd50eb7ebdb3dec9d8c602472f14042
Author: Philip Withnall <philip tecnocode co uk>
Date:   Sun Apr 20 21:08:55 2014 +0100

    tracker: Fix crash on handling invalid birthday dates from contacts
    
    If a GDateTime cannot be constructed due to the requested date being
    invalid or out of range, the constructor will return null. The code was
    not previously handling this.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=727944

 backends/tracker/lib/trf-persona.vala |   10 +++++++---
 1 files changed, 7 insertions(+), 3 deletions(-)
---
diff --git a/backends/tracker/lib/trf-persona.vala b/backends/tracker/lib/trf-persona.vala
index 71b4a24..dee10d6 100644
--- a/backends/tracker/lib/trf-persona.vala
+++ b/backends/tracker/lib/trf-persona.vala
@@ -959,9 +959,13 @@ public class Trf.Persona : Folks.Persona,
       if (birthday != null && birthday != "")
         {
           TimeVal t = TimeVal ();
-          t.from_iso8601 (birthday);
-          this._birthday = new DateTime.from_timeval_utc (t);
-          this.notify_property ("birthday");
+          if (t.from_iso8601 (birthday))
+            {
+              /* Note: This could return null if the timeval is invalid
+               * (e.g. out of range). That's OK. */
+              this._birthday = new DateTime.from_timeval_utc (t);
+              this.notify_property ("birthday");
+            }
         }
       else
         {


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