[tracker/wip/carlosg/coverity-fixes: 12/16] libtracker-data: Handle TrackerBinding together in code




commit c372fbc99ff7625d1f55a944bb48f1d6698bf529
Author: Carlos Garnacho <carlosg gnome org>
Date:   Sat Oct 23 14:20:04 2021 +0200

    libtracker-data: Handle TrackerBinding together in code
    
    This TrackerBinding was being created, attached to the TrackerVariable
    (which holds a ref), and unref. The binding is still alive when we set
    the type later. This confuses Coverity, so move all the handling of the
    TrackerBinding to stay together. This has no functional difference.
    
    CID: #1501142

 src/libtracker-data/tracker-sparql.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)
---
diff --git a/src/libtracker-data/tracker-sparql.c b/src/libtracker-data/tracker-sparql.c
index b562bd97d..d12786e45 100644
--- a/src/libtracker-data/tracker-sparql.c
+++ b/src/libtracker-data/tracker-sparql.c
@@ -5633,9 +5633,6 @@ translate_InlineDataOneVar (TrackerSparql  *sparql,
        _call_rule (sparql, NAMED_RULE_Var, error);
 
        var = _last_node_variable (sparql);
-       binding = tracker_variable_binding_new (var, NULL, NULL);
-       tracker_variable_set_sample_binding (var, TRACKER_VARIABLE_BINDING (binding));
-       g_object_unref (binding);
 
        _append_string (sparql, "(");
        _append_variable_sql (sparql, var);
@@ -5655,11 +5652,15 @@ translate_InlineDataOneVar (TrackerSparql  *sparql,
                n_values++;
        }
 
+       binding = tracker_variable_binding_new (var, NULL, NULL);
+       tracker_variable_set_sample_binding (var, TRACKER_VARIABLE_BINDING (binding));
+
        if (n_values == 0)
                _append_string (sparql, "SELECT NULL WHERE FALSE");
        else
                tracker_binding_set_data_type (binding, sparql->current_state->expression_type);
 
+       g_object_unref (binding);
        _expect (sparql, RULE_TYPE_LITERAL, LITERAL_CLOSE_BRACE);
        _append_string (sparql, ") ");
 


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