diff --git a/lib/filterx/expr-variable.c b/lib/filterx/expr-variable.c index 294ce636b..ba84a5fe5 100644 --- a/lib/filterx/expr-variable.c +++ b/lib/filterx/expr-variable.c @@ -48,14 +48,10 @@ _pull_variable_from_message(FilterXVariableExpr *self, FilterXEvalContext *conte return NULL; } - FilterXObject *msg_ref; if (log_msg_is_value_from_macro(value)) - msg_ref = filterx_message_value_new(value, value_len, t); + return filterx_message_value_new(value, value_len, t); else - msg_ref = filterx_message_value_new_borrowed(value, value_len, t); - - filterx_scope_register_variable(context->scope, self->handle, msg_ref); - return msg_ref; + return filterx_message_value_new_borrowed(value, value_len, t); } /* NOTE: unset on a variable that only exists in the LogMessage, without making the message writable */ @@ -84,7 +80,14 @@ _eval(FilterXExpr *s) } if (!filterx_variable_handle_is_floating(self->handle)) - return _pull_variable_from_message(self, context, context->msgs[0]); + { + FilterXObject *msg_ref = _pull_variable_from_message(self, context, context->msgs[0]); + if(!msg_ref) + return NULL; + filterx_scope_register_variable(context->scope, self->handle, msg_ref); + return msg_ref; + } + filterx_eval_push_error("No such variable", s, self->variable_name); return NULL; } diff --git a/lib/filterx/filterx-eval.h b/lib/filterx/filterx-eval.h index 14b0313a8..d8f96f0f7 100644 --- a/lib/filterx/filterx-eval.h +++ b/lib/filterx/filterx-eval.h @@ -63,7 +63,6 @@ void filterx_eval_push_error(const gchar *message, FilterXExpr *expr, FilterXObj void filterx_eval_push_error_info(const gchar *message, FilterXExpr *expr, gchar *info, gboolean free_info); void filterx_eval_set_context(FilterXEvalContext *context); FilterXEvalResult filterx_eval_exec(FilterXEvalContext *context, FilterXExpr *expr, LogMessage *msg); -void filterx_eval_sync_scope_and_message(FilterXScope *scope, LogMessage *msg); const gchar *filterx_eval_get_last_error(void); EVTTAG *filterx_format_last_error(void); EVTTAG *filterx_format_last_error_location(void);