terminal: fix undefined memory in Tabstops code

This commit is contained in:
Mitchell Hashimoto
2025-08-20 20:44:32 -07:00
parent be51f3e729
commit 566062c0a5
3 changed files with 28 additions and 0 deletions

View File

@@ -937,6 +937,9 @@ test init {
}
test "add full" {
// This test is way too slow to run under Valgrind, unfortunately.
if (std.valgrind.runningOnValgrind() > 0) return error.SkipZigTest;
const testing = std.testing;
const alloc = testing.allocator;
const testFont = font.embedded.regular;

View File

@@ -129,6 +129,7 @@ pub fn resize(self: *Tabstops, alloc: Allocator, cols: usize) !void {
// Note: we can probably try to realloc here but I'm not sure it matters.
const new = try alloc.alloc(Unit, size);
@memset(new, 0);
if (self.dynamic_stops.len > 0) {
fastmem.copy(Unit, new, self.dynamic_stops);
alloc.free(self.dynamic_stops);

View File

@@ -3042,6 +3042,10 @@ test "Page moveCells graphemes" {
}
test "Page verifyIntegrity graphemes good" {
// Too slow, and not really necessary because the integrity tests are
// only run in debug builds and unit tests verify they work well enough.
if (std.valgrind.runningOnValgrind() > 0) return error.SkipZigTest;
var page = try Page.init(.{
.cols = 10,
.rows = 10,
@@ -3063,6 +3067,10 @@ test "Page verifyIntegrity graphemes good" {
}
test "Page verifyIntegrity grapheme row not marked" {
// Too slow, and not really necessary because the integrity tests are
// only run in debug builds and unit tests verify they work well enough.
if (std.valgrind.runningOnValgrind() > 0) return error.SkipZigTest;
var page = try Page.init(.{
.cols = 10,
.rows = 10,
@@ -3090,6 +3098,10 @@ test "Page verifyIntegrity grapheme row not marked" {
}
test "Page verifyIntegrity styles good" {
// Too slow, and not really necessary because the integrity tests are
// only run in debug builds and unit tests verify they work well enough.
if (std.valgrind.runningOnValgrind() > 0) return error.SkipZigTest;
var page = try Page.init(.{
.cols = 10,
.rows = 10,
@@ -3122,6 +3134,10 @@ test "Page verifyIntegrity styles good" {
}
test "Page verifyIntegrity styles ref count mismatch" {
// Too slow, and not really necessary because the integrity tests are
// only run in debug builds and unit tests verify they work well enough.
if (std.valgrind.runningOnValgrind() > 0) return error.SkipZigTest;
var page = try Page.init(.{
.cols = 10,
.rows = 10,
@@ -3160,6 +3176,10 @@ test "Page verifyIntegrity styles ref count mismatch" {
}
test "Page verifyIntegrity zero rows" {
// Too slow, and not really necessary because the integrity tests are
// only run in debug builds and unit tests verify they work well enough.
if (std.valgrind.runningOnValgrind() > 0) return error.SkipZigTest;
var page = try Page.init(.{
.cols = 10,
.rows = 10,
@@ -3174,6 +3194,10 @@ test "Page verifyIntegrity zero rows" {
}
test "Page verifyIntegrity zero cols" {
// Too slow, and not really necessary because the integrity tests are
// only run in debug builds and unit tests verify they work well enough.
if (std.valgrind.runningOnValgrind() > 0) return error.SkipZigTest;
var page = try Page.init(.{
.cols = 10,
.rows = 10,