mirror of
https://github.com/ghostty-org/ghostty.git
synced 2026-04-06 07:38:21 +00:00
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:
@@ -43,6 +43,7 @@ pub fn get(
|
||||
}
|
||||
|
||||
return switch (data) {
|
||||
.invalid => .invalid_value,
|
||||
inline else => |comptime_data| getTyped(
|
||||
comptime_data,
|
||||
@ptrCast(@alignCast(out)),
|
||||
|
||||
@@ -110,6 +110,7 @@ pub fn get(
|
||||
}
|
||||
|
||||
return switch (data) {
|
||||
.invalid => .invalid_value,
|
||||
inline else => |comptime_data| getTyped(
|
||||
cell_,
|
||||
comptime_data,
|
||||
|
||||
@@ -76,6 +76,7 @@ pub fn commandData(
|
||||
}
|
||||
|
||||
return switch (data) {
|
||||
.invalid => false,
|
||||
inline else => |comptime_data| commandDataTyped(
|
||||
command_,
|
||||
comptime_data,
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -73,6 +73,7 @@ pub fn get(
|
||||
}
|
||||
|
||||
return switch (data) {
|
||||
.invalid => .invalid_value,
|
||||
inline else => |comptime_data| getTyped(
|
||||
row_,
|
||||
comptime_data,
|
||||
|
||||
@@ -196,6 +196,7 @@ pub fn get(
|
||||
}
|
||||
|
||||
return switch (data) {
|
||||
.invalid => .invalid_value,
|
||||
inline else => |comptime_data| getTyped(
|
||||
terminal_,
|
||||
comptime_data,
|
||||
|
||||
Reference in New Issue
Block a user