[tracker/wip/carlosg/release-memory: 4/5] libtracker-data: Plug leak




commit 8a577d6a3efb822fb04d8f9be592d79ed7525b4c
Author: Carlos Garnacho <carlosg gnome org>
Date:   Sun Aug 30 19:41:14 2020 +0200

    libtracker-data: Plug leak
    
    The graph token was consistently being possibly leaked, if it had
    to be used again further on in the same query string.

 src/libtracker-data/tracker-sparql.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)
---
diff --git a/src/libtracker-data/tracker-sparql.c b/src/libtracker-data/tracker-sparql.c
index 5a2795af9..5b2f9ebf2 100644
--- a/src/libtracker-data/tracker-sparql.c
+++ b/src/libtracker-data/tracker-sparql.c
@@ -3896,6 +3896,7 @@ translate_Clear (TrackerSparql  *sparql,
                        break;
        }
 
+       tracker_token_unset (&sparql->current_state.graph);
        g_list_free (graphs);
 
        return handle_silent (silent, inner_error, error);
@@ -3956,6 +3957,7 @@ translate_Drop (TrackerSparql  *sparql,
        }
 
        g_list_free_full (graphs, g_free);
+       tracker_token_unset (&sparql->current_state.graph);
 
        return handle_silent (silent, inner_error, error);
 }
@@ -4001,9 +4003,13 @@ translate_Create (TrackerSparql  *sparql,
                                                &inner_error))
                goto error;
 
+       tracker_token_unset (&sparql->current_state.graph);
+
        return TRUE;
 
 error:
+       tracker_token_unset (&sparql->current_state.graph);
+
        return handle_silent (silent, inner_error, error);
 }
 
@@ -4024,11 +4030,13 @@ translate_Add (TrackerSparql  *sparql,
 
        _call_rule (sparql, NAMED_RULE_GraphOrDefault, error);
        source = g_strdup (tracker_token_get_idstring (&sparql->current_state.graph));
+       tracker_token_unset (&sparql->current_state.graph);
 
        _expect (sparql, RULE_TYPE_LITERAL, LITERAL_TO);
 
        _call_rule (sparql, NAMED_RULE_GraphOrDefault, error);
        destination = g_strdup (tracker_token_get_idstring (&sparql->current_state.graph));
+       tracker_token_unset (&sparql->current_state.graph);
 
        if (g_strcmp0 (source, destination) == 0) {
                g_free (source);
@@ -4094,11 +4102,13 @@ translate_Move (TrackerSparql  *sparql,
 
        _call_rule (sparql, NAMED_RULE_GraphOrDefault, error);
        source = g_strdup (tracker_token_get_idstring (&sparql->current_state.graph));
+       tracker_token_unset (&sparql->current_state.graph);
 
        _expect (sparql, RULE_TYPE_LITERAL, LITERAL_TO);
 
        _call_rule (sparql, NAMED_RULE_GraphOrDefault, error);
        destination = g_strdup (tracker_token_get_idstring (&sparql->current_state.graph));
+       tracker_token_unset (&sparql->current_state.graph);
 
        if (g_strcmp0 (source, destination) == 0) {
                g_free (source);
@@ -4174,6 +4184,7 @@ translate_Copy (TrackerSparql  *sparql,
        g_assert (!tracker_token_is_empty (&sparql->current_state.graph) ||
                  sparql->current_state.graph_op == GRAPH_OP_DEFAULT);
        source = g_strdup (tracker_token_get_idstring (&sparql->current_state.graph));
+       tracker_token_unset (&sparql->current_state.graph);
 
        _expect (sparql, RULE_TYPE_LITERAL, LITERAL_TO);
 
@@ -4181,6 +4192,7 @@ translate_Copy (TrackerSparql  *sparql,
        g_assert (!tracker_token_is_empty (&sparql->current_state.graph) ||
                  sparql->current_state.graph_op == GRAPH_OP_DEFAULT);
        destination = g_strdup (tracker_token_get_idstring (&sparql->current_state.graph));
+       tracker_token_unset (&sparql->current_state.graph);
 
        if (g_strcmp0 (source, destination) == 0) {
                g_free (source);


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