Fix: cli: increment bt_value_null ref count when returning null value
authorSimon Marchi <simon.marchi@efficios.com>
Thu, 15 Aug 2019 15:24:24 +0000 (11:24 -0400)
committerPhilippe Proulx <eeppeliteloop@gmail.com>
Sat, 17 Aug 2019 00:12:13 +0000 (20:12 -0400)
The ini_parse_value function returns a new reference to a value.
When return a null value, it needs to acquire a new reference to
bt_value_null to account for that.

A crash can be triggered because of this bug with:

    $ LIBBABELTRACE2_INIT_LOG_LEVEL=W ~/build/babeltrace/src/cli/babeltrace2 -c src.ctf.fs --params='yo=null,madame=null,la=null'
    08-15 11:27:23.947  8793  8793 W LIB/VALUE bt_value_null_instance_release_func@value.c:72 Releasing the null value singleton: addr=0x7fb46d3038e0
    08-15 11:27:23.947  8793  8793 F LIB/VALUE bt_object_put_ref@object.h:367 Babeltrace 2 library precondition not satisfied; error is:
    08-15 11:27:23.947  8793  8793 F LIB/VALUE bt_object_put_ref@object.h:367 Decrementing a reference count set to 0: addr=0x7fb46d3038e0, ref-count=0
    08-15 11:27:23.947  8793  8793 F LIB/VALUE bt_object_put_ref@object.h:367 Aborting...

Change-Id: I6748fd9d8a7ba89728f0e4ddb9ea62bf423fdc91
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/1941
Tested-by: jenkins <jenkins@lttng.org>
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
src/cli/babeltrace2-cfg-cli-params-arg.c

index e5662c698f247763116a89c6d821034d885641d1..79cde92970a53d49d221fc9e100daf61c3abc941 100644 (file)
@@ -320,6 +320,7 @@ bt_value *ini_parse_value(struct ini_parsing_state *state)
                if (strcmp(id, "null") == 0 || strcmp(id, "NULL") == 0 ||
                                strcmp(id, "nul") == 0) {
                        value = bt_value_null;
+                       bt_value_get_ref(value);
                } else if (strcmp(id, "true") == 0 || strcmp(id, "TRUE") == 0 ||
                                strcmp(id, "yes") == 0 ||
                                strcmp(id, "YES") == 0) {
This page took 0.030588 seconds and 4 git commands to generate.