Fix: Possible dereference of null pointers
[lttng-tools.git] / src / lib / lttng-ctl / filter / filter-visitor-set-parent.c
index fd895f6f1e8003b45f591f421d38b5b1aaa08d84..458688da44a13b4d924be20162b7d15e46f575eb 100644 (file)
 #include "filter-ast.h"
 #include "filter-parser.h"
 
+#include <common/macros.h>
+
 static
 int update_child(struct filter_node *parent,
                struct filter_node *old_child,
                struct filter_node *new_child)
 {
+       if (!parent) {
+               fprintf(stderr, "[error] %s: NULL parent\n", __func__);
+               return -EINVAL;
+       }
+
        switch (parent->type) {
        case NODE_UNKNOWN:
        default:
@@ -91,7 +98,8 @@ int recursive_visit_set_parent(struct filter_node *node,
                        return -EINVAL;
                case AST_EXP_NESTED:
                        return recursive_visit_set_parent(node->u.expression.u.child, node);
-               case AST_EXP_IDENTIFIER:
+               case AST_EXP_IDENTIFIER:        /* fall-through */
+               case AST_EXP_GLOBAL_IDENTIFIER:
                        {
                                struct filter_node *orig_node = node;
 
@@ -100,7 +108,8 @@ int recursive_visit_set_parent(struct filter_node *node,
 
                                        prev = node->u.expression.prev;
                                        if (prev->type != NODE_EXPRESSION ||
-                                               prev->u.expression.type != AST_EXP_IDENTIFIER) {
+                                               (prev->u.expression.type != AST_EXP_IDENTIFIER
+                                               && prev->u.expression.type != AST_EXP_GLOBAL_IDENTIFIER)) {
                                                fprintf(stderr, "[error] %s: expecting identifier before link\n", __func__);
                                                return -EINVAL;
                                        }
@@ -133,7 +142,7 @@ int recursive_visit_set_parent(struct filter_node *node,
        return 0;
 }
 
-__attribute__((visibility("hidden")))
+LTTNG_HIDDEN
 int filter_visitor_set_parent(struct filter_parser_ctx *ctx)
 {
        return recursive_visit_set_parent(&ctx->ast->root, NULL);
This page took 0.036669 seconds and 4 git commands to generate.