Add type check to nativefs.getDirectoryItems(dir)

Most incorrect types for 'dir' are caught deeper into the call stack, but passing nil causes a coredump. This type-check mirrors the behavior of love.filesystem.getDirectoryItems().
This commit is contained in:
rabbitboots
2022-02-28 15:56:17 -04:00
committed by GitHub
parent d78b4f3246
commit 975de5de9e

View File

@@ -351,6 +351,9 @@ local function withTempMount(dir, fn, ...)
end
function nativefs.getDirectoryItems(dir)
if type(dir) ~= "string" then
error("bad argument #1 to 'getDirectoryItems' (string expected, got " .. type(dir) .. ")")
end
local result, err = withTempMount(dir, love.filesystem.getDirectoryItems)
return result or {}
end