Fix: param-validation: remove memory leaks
[babeltrace.git] / src / plugins / common / param-validation / param-validation.c
index ca80e888add31aa156ae4bbcec2c3730bb46d3d7..b52332bcaac106cb6a8f4f2b44947abd43f45cc5 100644 (file)
@@ -400,10 +400,10 @@ enum bt_param_validation_status bt_param_validation_validate(
        struct bt_param_validation_map_value_descr map_value_descr;
        enum bt_param_validation_status status;
 
-       ctx.error = NULL;
+       memset(&ctx, '\0', sizeof(ctx));
+
        ctx.scope_stack = g_array_new(FALSE, FALSE,
                sizeof(struct validate_ctx_stack_element));
-                       g_ptr_array_new_with_free_func(g_free);
        if (!ctx.scope_stack) {
                status = BT_PARAM_VALIDATION_STATUS_MEMORY_ERROR;
                goto end;
@@ -417,5 +417,9 @@ end:
        *error = ctx.error;
        ctx.error = NULL;
 
+       if (ctx.scope_stack) {
+               g_array_free(ctx.scope_stack, TRUE);
+       }
+
        return status;
 }
This page took 0.023111 seconds and 4 git commands to generate.