From 975de5de9eb5bd284feeb1be193a98373dfb6a39 Mon Sep 17 00:00:00 2001 From: rabbitboots Date: Mon, 28 Feb 2022 15:56:17 -0400 Subject: [PATCH] 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(). --- nativefs.lua | 3 +++ 1 file changed, 3 insertions(+) diff --git a/nativefs.lua b/nativefs.lua index 16e7ca9..1a3739b 100644 --- a/nativefs.lua +++ b/nativefs.lua @@ -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