[tracker-miners/wip/carlosg/coverity-fixes: 14/28] tracker-writeback: Plug leak




commit 37fb76a284822d5da28256c36aec41d4707358fe
Author: Carlos Garnacho <carlosg gnome org>
Date:   Sun Oct 24 00:59:32 2021 +0200

    tracker-writeback: Plug leak
    
    The filename variable was not being freed.
    
    CID: #365669

 src/tracker-writeback/tracker-writeback-gstreamer.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)
---
diff --git a/src/tracker-writeback/tracker-writeback-gstreamer.c 
b/src/tracker-writeback/tracker-writeback-gstreamer.c
index a58fa60ad..e2c2ed1ec 100644
--- a/src/tracker-writeback/tracker-writeback-gstreamer.c
+++ b/src/tracker-writeback/tracker-writeback-gstreamer.c
@@ -516,14 +516,14 @@ generate_gst_sample_from_image (const GValue *val)
        const gchar *image_url = g_value_get_string (val);
 
        filename = g_filename_from_uri (image_url, NULL, &err);
-       if (err != NULL) {
+       if (!filename && err != NULL) {
                g_warning ("could not get filename for url (%s): %s", image_url, err->message);
                g_clear_error (&err);
                return img_sample;
        }
 
        mapped_file = g_mapped_file_new (filename, TRUE, &err);
-       if (err != NULL) {
+       if (!mapped_file && err != NULL) {
                g_warning ("encountered error reading image file (%s): %s", filename, err->message);
                g_error_free (err);
        } else {
@@ -531,10 +531,12 @@ generate_gst_sample_from_image (const GValue *val)
                byte_arr = g_bytes_unref_to_array (bytes);
                img_sample = gst_tag_image_data_to_image_sample (byte_arr->data,
                                                                 byte_arr->len, GST_TAG_IMAGE_TYPE_NONE);
+               g_byte_array_unref (byte_arr);
+               g_mapped_file_unref (mapped_file);
        }
 
-       g_byte_array_unref (byte_arr);
-       g_mapped_file_unref (mapped_file);
+       g_free (filename);
+
        return img_sample;
 }
 


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