Skip to content

Commit

Permalink
fix: do not crash when failing to read input
Browse files Browse the repository at this point in the history
  • Loading branch information
hishamhm committed Aug 19, 2024
1 parent 57f1c61 commit 4dffbe8
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
4 changes: 4 additions & 0 deletions tl.lua
Original file line number Diff line number Diff line change
Expand Up @@ -12806,6 +12806,10 @@ end
local function read_full_file(fd)
local bom = "\239\187\191"
local content, err = fd:read("*a")
if not content then
return nil, err
end

if content:sub(1, bom:len()) == bom then
content = content:sub(bom:len() + 1)
end
Expand Down
4 changes: 4 additions & 0 deletions tl.tl
Original file line number Diff line number Diff line change
Expand Up @@ -12806,6 +12806,10 @@ end
local function read_full_file(fd: FILE): string, string
local bom <const> = "\239\187\191" -- "\xEF\xBB\xBF"
local content, err = fd:read("*a")
if not content then
return nil, err
end

if content:sub(1, bom:len()) == bom then
content = content:sub(bom:len() + 1)
end
Expand Down

0 comments on commit 4dffbe8

Please sign in to comment.