[tracker/wip/carlosg/invalid-reads] libtracker-data: Break out of all loops on transaction errors




commit 8b83c5f70b06902c63c2331d8195f9513ef15f7b
Author: Carlos Garnacho <carlosg gnome org>
Date:   Sun Oct 11 13:48:36 2020 +0200

    libtracker-data: Break out of all loops on transaction errors
    
    If an error is found when flushing a transaction on a specific, we'd
    inadvertently still try to handle operations in other graphs, possibly
    reusing the GError location, and leading to invalid reads/writes.
    
    After finding an error, the transaction is going to be rolled back
    anyway, so break on the first error found.
    
    Fixes: https://gitlab.gnome.org/GNOME/tracker-miners/-/issues/130

 src/libtracker-data/tracker-data-update.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
---
diff --git a/src/libtracker-data/tracker-data-update.c b/src/libtracker-data/tracker-data-update.c
index 86a707dde..f5c1c2af8 100644
--- a/src/libtracker-data/tracker-data-update.c
+++ b/src/libtracker-data/tracker-data-update.c
@@ -1147,11 +1147,12 @@ tracker_data_update_buffer_flush (TrackerData  *data,
                        tracker_data_resource_buffer_flush (data, resource, &actual_error);
                        if (actual_error) {
                                g_propagate_error (error, actual_error);
-                               break;
+                               goto out;
                        }
                }
        }
 
+out:
        g_ptr_array_set_size (data->update_buffer.graphs, 0);
        data->resource_buffer = NULL;
 }


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