authorgravatar for hello@nektro.netMeghan Denny <hello@nektro.net> 2021-03-20 12:03:26 -07:00
committergravatar for hello@nektro.netMeghan Denny <hello@nektro.net> 2021-03-20 12:03:26 -07:00
log9c5c5c9e2aef6fddf2a9efbf0ea841b5e20ed6aa
treeda08eee46df8c1ff3517e940bb6c4099c55d2507
parent8d81d0bdb157997e6f4e1a8a556fe6e82941cbe8

util/modfile- fix crash with deps with no version


1 files changed, 5 insertions(+), 2 deletions(-)

src/util/modfile.zig+5-2
......@@ -44,7 +44,7 @@ pub const ModFile = struct {
4444 for (dep_seq.sequence) |item| {
4545 var dtype: []const u8 = undefined;
4646 var path: []const u8 = undefined;
47 var version: []const u8 = undefined;
47 var version: ?[]const u8 = null;
4848 if (item.mapping.get("src")) |val| {
4949 var src_iter = std.mem.tokenize(val.string, " ");
5050 dtype = src_iter.next().?;
......@@ -59,6 +59,9 @@ pub const ModFile = struct {
5959 if (item.mapping.get("version")) |verv| {
6060 version = verv.string;
6161 }
62 if (version == null) {
63 version = "";
64 }
6265 const dep_type = std.meta.stringToEnum(u.DepType, dtype).?;
6366
6467 try dep_list.append(u.Dep{
......@@ -67,7 +70,7 @@ pub const ModFile = struct {
6770 .id = item.mapping.get_string("id"),
6871 .name = item.mapping.get_string("name"),
6972 .main = item.mapping.get_string("main"),
70 .version = version,
73 .version = version.?,
7174 .c_include_dirs = try item.mapping.get_string_array(alloc, "c_include_dirs"),
7275 .c_source_flags = try item.mapping.get_string_array(alloc, "c_source_flags"),
7376 .c_source_files = try item.mapping.get_string_array(alloc, "c_source_files"),