vt: handle invalid enum before pointer cast in getters

The inline else switch in each C API getter expands the .invalid
case, which has OutType void. When called with .invalid and a null
out pointer, the @ptrCast(@alignCast(out)) panics before getTyped
can return early.

Handle .invalid explicitly in the outer switch of every getter to
short-circuit before the pointer cast. This affects build_info,
cell, row, terminal, osc, and render (three getters).
This commit is contained in:
Mitchell Hashimoto
2026-03-23 09:19:32 -07:00
parent 409f05c927
commit 58283528c7
6 changed files with 8 additions and 0 deletions

View File

@@ -43,6 +43,7 @@ pub fn get(
}
return switch (data) {
.invalid => .invalid_value,
inline else => |comptime_data| getTyped(
comptime_data,
@ptrCast(@alignCast(out)),

View File

@@ -110,6 +110,7 @@ pub fn get(
}
return switch (data) {
.invalid => .invalid_value,
inline else => |comptime_data| getTyped(
cell_,
comptime_data,

View File

@@ -76,6 +76,7 @@ pub fn commandData(
}
return switch (data) {
.invalid => false,
inline else => |comptime_data| commandDataTyped(
command_,
comptime_data,

View File

@@ -193,6 +193,7 @@ pub fn get(
}
return switch (data) {
.invalid => .invalid_value,
inline else => |comptime_data| getTyped(
state_,
comptime_data,
@@ -467,6 +468,7 @@ pub fn row_cells_get(
}
return switch (data) {
.invalid => .invalid_value,
inline else => |comptime_data| rowCellsGetTyped(
cells_,
comptime_data,
@@ -566,6 +568,7 @@ pub fn row_get(
}
return switch (data) {
.invalid => .invalid_value,
inline else => |comptime_data| rowGetTyped(
iterator_,
comptime_data,

View File

@@ -73,6 +73,7 @@ pub fn get(
}
return switch (data) {
.invalid => .invalid_value,
inline else => |comptime_data| getTyped(
row_,
comptime_data,

View File

@@ -196,6 +196,7 @@ pub fn get(
}
return switch (data) {
.invalid => .invalid_value,
inline else => |comptime_data| getTyped(
terminal_,
comptime_data,