Fix: cli: check return value of bt_value_array_append_string_element
authorSimon Marchi <simon.marchi@efficios.com>
Sat, 17 Aug 2019 23:29:42 +0000 (19:29 -0400)
committerSimon Marchi <simon.marchi@efficios.com>
Mon, 26 Aug 2019 16:52:59 +0000 (12:52 -0400)
Found by coverity.

Change-Id: I7830920e70457d8281f57f4447d81fe194399821
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/1963
Tested-by: jenkins <jenkins@lttng.org>
Reviewed-by: Francis Deslauriers <francis.deslauriers@efficios.com>
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
src/cli/babeltrace2-cfg-cli-args.c

index 63a815e66d0ed82b9732962ca840ab7baab441d7..8a9c1bf6d6e705ca3295bdfc454794daa6ea9fc5 100644 (file)
@@ -3442,10 +3442,16 @@ struct bt_config *bt_config_convert_from_args(int argc, const char *argv[],
                                         * it in `non_opt_params`.
                                         */
                                        bt_value *array;
+                                       bt_value_array_append_element_status append_element_status;
                                        uint64_t idx = bt_value_array_get_length(non_opt_params) - 1;
 
                                        array = bt_value_array_borrow_element_by_index(non_opt_params, idx);
-                                       bt_value_array_append_string_element(array, arg);
+
+                                       append_element_status = bt_value_array_append_string_element(array, arg);
+                                       if (append_element_status != BT_VALUE_ARRAY_APPEND_ELEMENT_STATUS_OK) {
+                                               BT_CLI_LOGE_APPEND_CAUSE_OOM();
+                                               goto error;
+                                       }
                                } else {
                                        BT_CLI_LOGE_APPEND_CAUSE(
                                                "No current component (--component option) or non-option argument of which to set parameters:\n    %s",
This page took 0.026229 seconds and 4 git commands to generate.