Skip to content

Segmentation fault when destroy a String with default #44

@kioz-wang

Description

@kioz-wang

Look at the code:

test "Bug, destroy default String" {
    const cmd = Command.new("cmd").arg(Arg.posArg("pos", String).default("hello"));
    var it = try TokenIter.initList(&.{}, .{});
    const args = try cmd.parseFrom(&it, testing.allocator);
    cmd.destroy(&args, testing.allocator);
}

It would raise segmentation fault because that allocator attempts to free the memory of "hello".

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions