[tracker] examples: Check for NULL cursors in class-signal example
- From: Carlos Garnacho <carlosg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [tracker] examples: Check for NULL cursors in class-signal example
- Date: Sat, 28 Jan 2017 12:08:10 +0000 (UTC)
commit 9c2caec7d07628755e78790af8805e12ec2d8e9e
Author: Carlos Garnacho <carlosg gnome org>
Date: Sat Jan 28 12:55:27 2017 +0100
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
examples/libtracker-sparql/class-signal.c | 9 +++++++++
1 files changed, 9 insertions(+), 0 deletions(-)
---
diff --git a/examples/libtracker-sparql/class-signal.c b/examples/libtracker-sparql/class-signal.c
index 3ba2ab3..63fce7b 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");
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]