Commit 12051b02f1
lib/std/fs/path.zig
@@ -1110,7 +1110,7 @@ pub fn relativePosix(allocator: *Allocator, from: []const u8, to: []const u8) ![
}
if (to_rest.len == 0) {
// shave off the trailing slash
- return result[0 .. result_index - 1];
+ return allocator.shrink(result, result_index - 1);
}
mem.copy(u8, result[result_index..], to_rest);
lib/std/math/big/int.zig
@@ -619,6 +619,9 @@ pub const Mutable = struct {
var r = try Managed.init(limbs_buffer.allocator);
defer r.deinit();
+ var tmp_x = try Managed.init(limbs_buffer.allocator);
+ defer tmp_x.deinit();
+
while (y.len() > 1) {
assert(x.isPositive() and y.isPositive());
assert(x.len() >= y.len());
@@ -670,7 +673,8 @@ pub const Mutable = struct {
try t_big.add(r.toConst(), t_big.toConst());
// u = Cx + Dy, r as u
- try x.mul(x.toConst(), Cp);
+ try tmp_x.copy(x.toConst());
+ try x.mul(tmp_x.toConst(), Cp);
try r.mul(y.toConst(), Dp);
try r.add(x.toConst(), r.toConst());
test/tests.zig
@@ -648,8 +648,9 @@ pub const StackTracesContext = struct {
const stdout = child.stdout.?.inStream().readAllAlloc(b.allocator, max_stdout_size) catch unreachable;
defer b.allocator.free(stdout);
- var stderr = child.stderr.?.inStream().readAllAlloc(b.allocator, max_stdout_size) catch unreachable;
- defer b.allocator.free(stderr);
+ const stderrFull = child.stderr.?.inStream().readAllAlloc(b.allocator, max_stdout_size) catch unreachable;
+ defer b.allocator.free(stderrFull);
+ var stderr = stderrFull;
const term = child.wait() catch |err| {
debug.panic("Unable to spawn {}: {}\n", .{ full_exe_path, @errorName(err) });