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 {...@@ -44,7 +44,7 @@ pub const ModFile = struct {
44 for (dep_seq.sequence) |item| {44 for (dep_seq.sequence) |item| {
45 var dtype: []const u8 = undefined;45 var dtype: []const u8 = undefined;
46 var path: []const u8 = undefined;46 var path: []const u8 = undefined;
47 var version: []const u8 = undefined;47 var version: ?[]const u8 = null;
48 if (item.mapping.get("src")) |val| {48 if (item.mapping.get("src")) |val| {
49 var src_iter = std.mem.tokenize(val.string, " ");49 var src_iter = std.mem.tokenize(val.string, " ");
50 dtype = src_iter.next().?;50 dtype = src_iter.next().?;
...@@ -59,6 +59,9 @@ pub const ModFile = struct {...@@ -59,6 +59,9 @@ pub const ModFile = struct {
59 if (item.mapping.get("version")) |verv| {59 if (item.mapping.get("version")) |verv| {
60 version = verv.string;60 version = verv.string;
61 }61 }
62 if (version == null) {
63 version = "";
64 }
62 const dep_type = std.meta.stringToEnum(u.DepType, dtype).?;65 const dep_type = std.meta.stringToEnum(u.DepType, dtype).?;
6366
64 try dep_list.append(u.Dep{67 try dep_list.append(u.Dep{
...@@ -67,7 +70,7 @@ pub const ModFile = struct {...@@ -67,7 +70,7 @@ pub const ModFile = struct {
67 .id = item.mapping.get_string("id"),70 .id = item.mapping.get_string("id"),
68 .name = item.mapping.get_string("name"),71 .name = item.mapping.get_string("name"),
69 .main = item.mapping.get_string("main"),72 .main = item.mapping.get_string("main"),
70 .version = version,73 .version = version.?,
71 .c_include_dirs = try item.mapping.get_string_array(alloc, "c_include_dirs"),74 .c_include_dirs = try item.mapping.get_string_array(alloc, "c_include_dirs"),
72 .c_source_flags = try item.mapping.get_string_array(alloc, "c_source_flags"),75 .c_source_flags = try item.mapping.get_string_array(alloc, "c_source_flags"),
73 .c_source_files = try item.mapping.get_string_array(alloc, "c_source_files"),76 .c_source_files = try item.mapping.get_string_array(alloc, "c_source_files"),