Fix: cli: Acquire reference on bt_value_null while parsing args
authorSimon Marchi <simon.marchi@efficios.com>
Thu, 18 Apr 2019 18:00:29 +0000 (14:00 -0400)
committerFrancis Deslauriers <francis.deslauriers@efficios.com>
Thu, 2 May 2019 20:50:15 +0000 (20:50 +0000)
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 <simon.marchi@efficios.com>
cli/babeltrace-cfg-cli-args.c

index f501ebcdcf26db8811e00a35c3b5bf2e8d3aa138..920d2a3f5041f981de78a5646fb55566ddd7dd72 100644 (file)
@@ -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);
This page took 0.028322 seconds and 4 git commands to generate.