authorgravatar for johnnymarler@gmail.comJonathan Marler <johnnymarler@gmail.com> 2020-06-03 15:55:18-06:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2020-06-09 00:17:22-04:00
log12051b02f1f455b85d5a519dd1747a67d4bb68d0
tree4b773a1821e7b375e72734969918859d8aba5764
parent9ee98f103b3c8eb7f5775943725af4d38da36d2c

fix memory errors


3 files changed, 9 insertions(+), 4 deletions(-)

lib/std/fs/path.zig+1-1
...@@ -1110,7 +1110,7 @@ pub fn relativePosix(allocator: *Allocator, from: []const u8, to: []const u8) ![...@@ -1110,7 +1110,7 @@ pub fn relativePosix(allocator: *Allocator, from: []const u8, to: []const u8) ![
1110 }1110 }
1111 if (to_rest.len == 0) {1111 if (to_rest.len == 0) {
1112 // shave off the trailing slash1112 // shave off the trailing slash
1113 return result[0 .. result_index - 1];1113 return allocator.shrink(result, result_index - 1);
1114 }1114 }
11151115
1116 mem.copy(u8, result[result_index..], to_rest);1116 mem.copy(u8, result[result_index..], to_rest);
lib/std/math/big/int.zig+5-1
...@@ -619,6 +619,9 @@ pub const Mutable = struct {...@@ -619,6 +619,9 @@ pub const Mutable = struct {
619 var r = try Managed.init(limbs_buffer.allocator);619 var r = try Managed.init(limbs_buffer.allocator);
620 defer r.deinit();620 defer r.deinit();
621621
622 var tmp_x = try Managed.init(limbs_buffer.allocator);
623 defer tmp_x.deinit();
624
622 while (y.len() > 1) {625 while (y.len() > 1) {
623 assert(x.isPositive() and y.isPositive());626 assert(x.isPositive() and y.isPositive());
624 assert(x.len() >= y.len());627 assert(x.len() >= y.len());
...@@ -670,7 +673,8 @@ pub const Mutable = struct {...@@ -670,7 +673,8 @@ pub const Mutable = struct {
670 try t_big.add(r.toConst(), t_big.toConst());673 try t_big.add(r.toConst(), t_big.toConst());
671674
672 // u = Cx + Dy, r as u675 // u = Cx + Dy, r as u
673 try x.mul(x.toConst(), Cp);676 try tmp_x.copy(x.toConst());
677 try x.mul(tmp_x.toConst(), Cp);
674 try r.mul(y.toConst(), Dp);678 try r.mul(y.toConst(), Dp);
675 try r.add(x.toConst(), r.toConst());679 try r.add(x.toConst(), r.toConst());
676680
test/tests.zig+3-2
...@@ -648,8 +648,9 @@ pub const StackTracesContext = struct {...@@ -648,8 +648,9 @@ pub const StackTracesContext = struct {
648648
649 const stdout = child.stdout.?.inStream().readAllAlloc(b.allocator, max_stdout_size) catch unreachable;649 const stdout = child.stdout.?.inStream().readAllAlloc(b.allocator, max_stdout_size) catch unreachable;
650 defer b.allocator.free(stdout);650 defer b.allocator.free(stdout);
651 var stderr = child.stderr.?.inStream().readAllAlloc(b.allocator, max_stdout_size) catch unreachable;651 const stderrFull = child.stderr.?.inStream().readAllAlloc(b.allocator, max_stdout_size) catch unreachable;
652 defer b.allocator.free(stderr);652 defer b.allocator.free(stderrFull);
653 var stderr = stderrFull;
653654
654 const term = child.wait() catch |err| {655 const term = child.wait() catch |err| {
655 debug.panic("Unable to spawn {}: {}\n", .{ full_exe_path, @errorName(err) });656 debug.panic("Unable to spawn {}: {}\n", .{ full_exe_path, @errorName(err) });