From 130417948312e8aa9ab10b077953d40c9a56101b Mon Sep 17 00:00:00 2001 From: Simon Marchi Date: Thu, 18 Apr 2019 14:00:29 -0400 Subject: [PATCH] Fix: cli: Acquire reference on bt_value_null while parsing args In bt_config_query_from_args, we initialize "params" to point to bt_value_null without acquiring a reference: bt_value *params = bt_value_null; When handling OPT_PARAMS, lower, we call "put" on it before assigning params to something else: bt_value_put_ref(params); This causes bt_value_null's refcount to drop to 0 and its release to be called (which should never happen, since its refcount is initialized to 1). This warning is shown: $ ./cli/babeltrace query ... 04-18 13:56:12.267 10081 10081 W VALUES bt_value_null_instance_release_func@value.c:73 Releasing the null value singleton: addr=0x7f882eaf1b60 Fix it by acquiring a new reference in the beginning. Signed-off-by: Simon Marchi --- cli/babeltrace-cfg-cli-args.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/cli/babeltrace-cfg-cli-args.c b/cli/babeltrace-cfg-cli-args.c index f501ebcd..920d2a3f 100644 --- a/cli/babeltrace-cfg-cli-args.c +++ b/cli/babeltrace-cfg-cli-args.c @@ -1993,7 +1993,10 @@ struct bt_config *bt_config_query_from_args(int argc, const char *argv[], int ret; struct bt_config *cfg = NULL; const char *leftover; - bt_value *params = bt_value_null; + bt_value *params; + + params = bt_value_null; + bt_value_get_ref(bt_value_null); *retcode = 0; cfg = bt_config_query_create(initial_plugin_paths); -- 2.34.1