Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: fix memory leaks related to updating config variables #595

Merged
merged 3 commits into from
Aug 23, 2022
Merged

fix: fix memory leaks related to updating config variables #595

merged 3 commits into from
Aug 23, 2022

Conversation

llogick
Copy link
Contributor

@llogick llogick commented Aug 22, 2022

note:
adds an edge case in analysis.makeScopeInternal to prevent
leaking memory when adding duplicate container fields w/ name "other"
but there really should be a check for duplicates

edit:

        if (container_field) |_| {
            if (!std.mem.eql(u8, name, "_")) {
                var doc = if (try getDocComments(allocator, tree, decl, .Markdown)) |docs|
                        types.MarkupContent{ .kind = .Markdown, .value = docs }
                    else
                        null;
                var gop_res = try context.enums.getOrPut(allocator, .{
                    .label = name,
                    .kind = .Constant,
                    .insertText = name,
                    .insertTextFormat = .PlainText,
                    .documentation = doc
                });
                if (gop_res.found_existing) {
                    if (doc) |d| allocator.free(d.value);
                }
            }
        }

adds an edge case in analysis.makeScopeInternal to prevent
leaking memory when adding duplicate container fields w/ name "other"
src/analysis.zig Outdated Show resolved Hide resolved
src/Server.zig Outdated Show resolved Hide resolved
@leecannon
Copy link
Member

Thanks for this!

@leecannon leecannon merged commit 7c245f7 into zigtools:master Aug 23, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants