From 0dacc15ec5f7780721bc6668dc81578706ad0d8c Mon Sep 17 00:00:00 2001 From: Meghan Denny Date: Thu, 28 Oct 2021 03:26:37 -0700 Subject: [PATCH] util/yaml- defer parser destroy so that it runs even if try fails --- src/util/yaml.zig | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/util/yaml.zig b/src/util/yaml.zig index b3a8c6d8a19132e774e40b72861db2f000b39de4..2f38ac77ce407c85657fabe12e20c997da9f3640 100644 --- a/src/util/yaml.zig +++ b/src/util/yaml.zig @@ -148,6 +148,7 @@ pub const TokenList = []const Token; pub fn parse(alloc: *std.mem.Allocator, input: string) !Document { var parser: c.yaml_parser_t = undefined; _ = c.yaml_parser_initialize(&parser); + defer c.yaml_parser_delete(&parser); const lines = try u.split(input, "\n"); @@ -170,8 +171,6 @@ pub fn parse(alloc: *std.mem.Allocator, input: string) !Document { } } - c.yaml_parser_delete(&parser); - const p = &Parser{ .alloc = alloc, .tokens = all_events.items, -- 2.54.0