Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/windirstat/premake-4.x-stable.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'src/host/os_match.c')
-rw-r--r--src/host/os_match.c13
1 files changed, 10 insertions, 3 deletions
diff --git a/src/host/os_match.c b/src/host/os_match.c
index 460bf5f..3e20282 100644
--- a/src/host/os_match.c
+++ b/src/host/os_match.c
@@ -36,9 +36,16 @@ int os_matchstart(lua_State* L)
{
const char* mask = luaL_checkstring(L, 1);
MatchInfo* m = (MatchInfo*)malloc(sizeof(MatchInfo));
- m->handle = FindFirstFile(mask, &m->entry); /* error handling happens in os_matchnext() below */
- m->is_first = 1;
- lua_pushlightuserdata(L, m);
+ if (m)
+ {
+ m->handle = FindFirstFile(mask, &m->entry); /* error handling happens in os_matchnext() below */
+ m->is_first = 1;
+ lua_pushlightuserdata(L, m);
+ }
+ else
+ {
+ lua_pushnil(L);
+ }
return 1;
}