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) ![
11101110 }
11111111 if (to_rest.len == 0) {
11121112 // shave off the trailing slash
1113 return result[0 .. result_index - 1];
1113 return allocator.shrink(result, result_index - 1);
11141114 }
11151115
11161116 mem.copy(u8, result[result_index..], to_rest);
lib/std/math/big/int.zig+5-1
......@@ -619,6 +619,9 @@ pub const Mutable = struct {
619619 var r = try Managed.init(limbs_buffer.allocator);
620620 defer r.deinit();
621621
622 var tmp_x = try Managed.init(limbs_buffer.allocator);
623 defer tmp_x.deinit();
624
622625 while (y.len() > 1) {
623626 assert(x.isPositive() and y.isPositive());
624627 assert(x.len() >= y.len());
......@@ -670,7 +673,8 @@ pub const Mutable = struct {
670673 try t_big.add(r.toConst(), t_big.toConst());
671674
672675 // 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);
674678 try r.mul(y.toConst(), Dp);
675679 try r.add(x.toConst(), r.toConst());
676680
test/tests.zig+3-2
......@@ -648,8 +648,9 @@ pub const StackTracesContext = struct {
648648
649649 const stdout = child.stdout.?.inStream().readAllAlloc(b.allocator, max_stdout_size) catch unreachable;
650650 defer b.allocator.free(stdout);
651 var stderr = child.stderr.?.inStream().readAllAlloc(b.allocator, max_stdout_size) catch unreachable;
652 defer b.allocator.free(stderr);
651 const stderrFull = child.stderr.?.inStream().readAllAlloc(b.allocator, max_stdout_size) catch unreachable;
652 defer b.allocator.free(stderrFull);
653 var stderr = stderrFull;
653654
654655 const term = child.wait() catch |err| {
655656 debug.panic("Unable to spawn {}: {}\n", .{ full_exe_path, @errorName(err) });