diff options
| author | Jeffrey C. Ollie <jeff@ocjtech.us> | 2025-02-07 22:20:37 -0600 |
|---|---|---|
| committer | Jeffrey C. Ollie <jeff@ocjtech.us> | 2025-02-08 15:17:25 -0600 |
| commit | 1947ba9c68446f3ec793906923d1d95e654ae649 (patch) | |
| tree | 0cf1e23f449619f5302a6f681c87f0e60b358b6c /src/cli/args.zig | |
| parent | f95f636f1fff1cf449efa79f3f42dcb8d9bbfce5 (diff) | |
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
Diffstat (limited to 'src/cli/args.zig')
| -rw-r--r-- | src/cli/args.zig | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/src/cli/args.zig b/src/cli/args.zig index 166b2daf5..7385e6a3e 100644 --- a/src/cli/args.zig +++ b/src/cli/args.zig @@ -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 |
