From 1ac6ca02ee2bb30af01736424fa9e51028b5b2db Mon Sep 17 00:00:00 2001 From: Amr Gharbeia Date: Thu, 14 May 2026 13:03:42 -0400 Subject: [PATCH] fix: handle nil env vars in backend-size parse-integer errors on nil input. Guard with when before parsing. --- src/backend/modern.lisp | 8 ++++---- src/backend/simple.lisp | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/backend/modern.lisp b/src/backend/modern.lisp index 4c15fcf..b9a8450 100644 --- a/src/backend/modern.lisp +++ b/src/backend/modern.lisp @@ -185,10 +185,10 @@ as a fallback when a keyword is not in *named-colors*.") ;; $LINES from the shell, which reflect the true size at ;; process start even when ioctl on stdout's fd disagrees. (or (ignore-errors - (let ((cols (parse-integer (sb-ext:posix-getenv "COLUMNS") - :junk-allowed t)) - (rows (parse-integer (sb-ext:posix-getenv "LINES") - :junk-allowed t))) + (let* ((cstr (sb-ext:posix-getenv "COLUMNS")) + (rstr (sb-ext:posix-getenv "LINES")) + (cols (when cstr (parse-integer cstr :junk-allowed t))) + (rows (when rstr (parse-integer rstr :junk-allowed t)))) (when (and cols rows (> cols 0) (> rows 0)) (values cols rows)))) (values w h))))) diff --git a/src/backend/simple.lisp b/src/backend/simple.lisp index 570ab9b..e2704a4 100644 --- a/src/backend/simple.lisp +++ b/src/backend/simple.lisp @@ -44,10 +44,10 @@ (if (and (> w 80) (> h 24)) (values w h) (or (ignore-errors - (let ((cols (parse-integer (sb-ext:posix-getenv "COLUMNS") - :junk-allowed t)) - (rows (parse-integer (sb-ext:posix-getenv "LINES") - :junk-allowed t))) + (let* ((cstr (sb-ext:posix-getenv "COLUMNS")) + (rstr (sb-ext:posix-getenv "LINES")) + (cols (when cstr (parse-integer cstr :junk-allowed t))) + (rows (when rstr (parse-integer rstr :junk-allowed t)))) (when (and cols rows (> cols 0) (> rows 0)) (values cols rows)))) (values w h)))))