mirror of
https://github.com/ghostty-org/ghostty.git
synced 2026-04-19 05:50:27 +00:00
core: protect against crashes and hangs when themes are not files
If a theme was not a file or a directory you could get a crash or a hang (depending on platform) if the theme references a directory. This patch also prevents attempts to load from other non-file sources. Fixes: #5596
This commit is contained in:
@@ -8,6 +8,8 @@ const internal_os = @import("../os/main.zig");
|
||||
const Diagnostic = diags.Diagnostic;
|
||||
const DiagnosticList = diags.DiagnosticList;
|
||||
|
||||
const log = std.log.scoped(.cli);
|
||||
|
||||
// TODO:
|
||||
// - Only `--long=value` format is accepted. Do we want to allow
|
||||
// `--long value`? Not currently allowed.
|
||||
@@ -1258,9 +1260,11 @@ pub fn LineIterator(comptime ReaderType: type) type {
|
||||
const buf = buf: {
|
||||
while (true) {
|
||||
// Read the full line
|
||||
var entry = self.r.readUntilDelimiterOrEof(self.entry[2..], '\n') catch {
|
||||
// TODO: handle errors
|
||||
unreachable;
|
||||
var entry = self.r.readUntilDelimiterOrEof(self.entry[2..], '\n') catch |err| switch (err) {
|
||||
inline else => |e| {
|
||||
log.warn("cannot read from \"{s}\": {}", .{ self.filepath, e });
|
||||
return null;
|
||||
},
|
||||
} orelse return null;
|
||||
|
||||
// Increment our line counter
|
||||
|
||||
Reference in New Issue
Block a user