summaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
authorCarlos Garnacho <carlosg@gnome.org>2017-01-28 12:55:27 +0100
committerCarlos Garnacho <carlosg@gnome.org>2017-01-28 13:05:42 +0100
commit9c2caec7d07628755e78790af8805e12ec2d8e9e (patch)
tree9107ceec0a0fd890d51bc55b54430d10e0c71dea /examples
parent385a7d4418365c51ccf0dd58f2520eaff4a8cd34 (diff)
downloadtracker-9c2caec7d07628755e78790af8805e12ec2d8e9e.tar.gz
examples: Check for NULL cursors in class-signal example
It is unlikely to receive errors on queries there, but still this is an example, so better be correct there. Coverity ID: 1188420
Diffstat (limited to 'examples')
-rw-r--r--examples/libtracker-sparql/class-signal.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/examples/libtracker-sparql/class-signal.c b/examples/libtracker-sparql/class-signal.c
index 3ba2ab3f4..63fce7be6 100644
--- a/examples/libtracker-sparql/class-signal.c
+++ b/examples/libtracker-sparql/class-signal.c
@@ -33,14 +33,23 @@ handle_statement (gint subject, gint predicate)
subject, predicate);
cursor = tracker_sparql_connection_query (con, query, NULL, NULL);
g_free (query);
+
+ if (!cursor)
+ return;
+
tracker_sparql_cursor_next (cursor, NULL, NULL);
pred = g_strdup (tracker_sparql_cursor_get_string (cursor, 1, NULL));
query = g_strdup_printf ("SELECT ?t { <%s> <%s> ?t }",
tracker_sparql_cursor_get_string (cursor, 0, NULL),
pred);
g_object_unref (cursor);
+
cursor = tracker_sparql_connection_query (con, query, NULL, NULL);
g_free (query);
+
+ if (!cursor)
+ return;
+
while (tracker_sparql_cursor_next (cursor, NULL, NULL))
g_print ("\t%s = %s\n", pred, tracker_sparql_cursor_get_string (cursor, 0, NULL));
g_print ("\n");