From: Simon Marchi Date: Thu, 18 Apr 2019 18:00:29 +0000 (-0400) Subject: Fix: cli: Acquire reference on bt_value_null while parsing args X-Git-Tag: v2.0.0-pre5~83 X-Git-Url: http://git.efficios.com/?p=babeltrace.git;a=commitdiff_plain;h=130417948312e8aa9ab10b077953d40c9a56101b 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 --- 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);