summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPablo Correa Gomez <ablocorrea@hotmail.com>2023-02-19 00:54:07 +0000
committerCorey Berla <corey@berla.me>2023-02-19 00:54:07 +0000
commit5f1680f9df8d6a62681a878975a1cec75a328a3d (patch)
treee86b55ae7686e5d5e2daf5b1e63f0b2b60e08002
parent52cf8f6da8a68cc4d46177bb4054d201f12bbba2 (diff)
downloadnautilus-5f1680f9df8d6a62681a878975a1cec75a328a3d.tar.gz
nautils-search-engine-tracker: Only parse non-null dates
Fix critical when parsing null date string: GLib-CRITICAL **: 12:05:52.144: g_time_val_from_iso8601: assertion 'iso_date != NULL' failed This is possible since tracker can return NULL[1] "if the column is not in the [0,#ncolumns] range" [1] https://gnome.pages.gitlab.gnome.org/tracker/docs/developer/tracker-sparql-cursor.html?gi-language=c#tracker_sparql_cursor_get_string
-rw-r--r--src/nautilus-search-engine-tracker.c23
1 files changed, 16 insertions, 7 deletions
diff --git a/src/nautilus-search-engine-tracker.c b/src/nautilus-search-engine-tracker.c
index 51917216b..bafc8148b 100644
--- a/src/nautilus-search-engine-tracker.c
+++ b/src/nautilus-search-engine-tracker.c
@@ -181,7 +181,7 @@ cursor_callback (GObject *object,
const char *atime_str;
const char *ctime_str;
const gchar *snippet;
- GDateTime *date;
+ GDateTime *date = NULL;
g_autoptr (GTimeZone) tz = g_time_zone_new_local ();
gdouble rank, match;
gboolean success;
@@ -232,31 +232,40 @@ cursor_callback (GObject *object,
}
}
- date = g_date_time_new_from_iso8601 (mtime_str, tz);
+ if (mtime_str != NULL)
+ {
+ date = g_date_time_new_from_iso8601 (mtime_str, tz);
+ }
if (date != NULL)
{
nautilus_search_hit_set_modification_time (hit, date);
- g_date_time_unref (date);
+ g_clear_pointer (&date, g_date_time_unref);
}
else
{
g_warning ("unable to parse mtime: %s", mtime_str);
}
- date = g_date_time_new_from_iso8601 (atime_str, tz);
+ if (atime_str != NULL)
+ {
+ date = g_date_time_new_from_iso8601 (atime_str, tz);
+ }
if (date != NULL)
{
nautilus_search_hit_set_access_time (hit, date);
- g_date_time_unref (date);
+ g_clear_pointer (&date, g_date_time_unref);
}
else
{
g_warning ("unable to parse atime: %s", atime_str);
}
- date = g_date_time_new_from_iso8601 (ctime_str, tz);
+ if (ctime_str != NULL)
+ {
+ date = g_date_time_new_from_iso8601 (ctime_str, tz);
+ }
if (date != NULL)
{
nautilus_search_hit_set_creation_time (hit, date);
- g_date_time_unref (date);
+ g_clear_pointer (&date, g_date_time_unref);
}
else
{