Skip to content

Commit 8cd7ef9

Browse files
Merge pull request #2449 from Jarod42/os_locate
[bugfix] Fix crash with invalid argument type passed to `os.locate`
2 parents ad29c23 + af17a73 commit 8cd7ef9

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

src/host/os_locate.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,10 @@ int os_locate(lua_State* L)
3636
for (i = 1; i <= nArgs; ++i) {
3737
const char* name = lua_tostring(L, i);
3838

39+
if (name == NULL) {
40+
continue;
41+
}
42+
3943
/* Direct path to an embedded file? */
4044
if (name[0] == '$' && name[1] == '/' && premake_find_embedded_script(name + 2)) {
4145
lua_pushvalue(L, i);

website/docs/os/os.locate.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
Searches the [Premake path](Locating-Scripts.md) for a file.
1+
Searches the [Premake path](Locating-Scripts.md) for files.
22

33
```lua
4-
os.locate("file_name")
4+
os.locate("file_name1", ...)
55
```
66

77
### Parameters ###
@@ -11,7 +11,7 @@ os.locate("file_name")
1111

1212
### Return Value ###
1313

14-
The full path to the file if found, or nil if the file could not be located.
14+
The full path to the first file found, or nil if the files could not be located.
1515

1616

1717
### Availability ###

0 commit comments

Comments
 (0)