[tracker/wip/carlosg/coverity-fixes: 16/16] libtracker-data: Avoid propagating errors based on uninitialized vars
- From: Carlos Garnacho <carlosg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [tracker/wip/carlosg/coverity-fixes: 16/16] libtracker-data: Avoid propagating errors based on uninitialized vars
- Date: Sat, 23 Oct 2021 18:42:01 +0000 (UTC)
commit 941fd6f44c6f34e93bb38acc31fd3496618d2855
Author: Carlos Garnacho <carlosg gnome org>
Date: Sat Oct 23 19:54:09 2021 +0200
libtracker-data: Avoid propagating errors based on uninitialized vars
If we fail to open the file entirely, we still would try to report
an error containing line/col info, even though these are not even
initialized.
Shuffle the code so we only report line/col for errors resulting
during parsing, and handle the open error separately.
CIDs: #1507946, #1507948
src/libtracker-data/tracker-data-update.c | 14 +++++---------
1 file changed, 5 insertions(+), 9 deletions(-)
---
diff --git a/src/libtracker-data/tracker-data-update.c b/src/libtracker-data/tracker-data-update.c
index 7aa28d509..c94fdc532 100644
--- a/src/libtracker-data/tracker-data-update.c
+++ b/src/libtracker-data/tracker-data-update.c
@@ -3121,11 +3121,11 @@ tracker_data_load_turtle_file (TrackerData *data,
const gchar *subject, *predicate, *object_str, *langtag;
gboolean object_is_uri;
goffset last_parsed_line_no, last_parsed_column_no;
- gchar *ontology_uri = g_file_get_uri (file);
+ gchar *ontology_uri;
- reader = tracker_turtle_reader_new_for_file (file, &inner_error);
- if (inner_error)
- goto failed;
+ reader = tracker_turtle_reader_new_for_file (file, error);
+ if (!reader)
+ return;
while (tracker_turtle_reader_next (reader,
&subject,
@@ -3161,10 +3161,6 @@ tracker_data_load_turtle_file (TrackerData *data,
goto failed;
}
- if (inner_error)
- goto failed;
-
- g_free (ontology_uri);
g_clear_object (&reader);
return;
@@ -3172,10 +3168,10 @@ tracker_data_load_turtle_file (TrackerData *data,
failed:
g_clear_object (&reader);
+ ontology_uri = g_file_get_uri (file);
g_propagate_prefixed_error (error, inner_error,
"%s:%" G_GOFFSET_FORMAT ":%" G_GOFFSET_FORMAT ": ",
ontology_uri, last_parsed_line_no, last_parsed_column_no);
-
g_free (ontology_uri);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]