NIXIO: TLS-Support, bugfixes
[project/luci.git] / libs / nixio / src / file.c
index 7b65abdc12a9374cee40f88278f9de445125ab0b..3333e23691575057849b9a5780726b19a7357994 100644 (file)
@@ -33,7 +33,11 @@ static int nixio_file(lua_State *L) {
                return nixio__perror(L);
        }
 
-       FILE **udata = lua_newuserdata(L, sizeof(FILE**));
+       FILE **udata = lua_newuserdata(L, sizeof(FILE*));
+       if (!udata) {
+               return luaL_error(L, "out of memory");
+       }
+
        *udata = file;
 
        luaL_getmetatable(L, NIXIO_FILE_META);
@@ -50,7 +54,11 @@ static int nixio_pipe(lua_State *L) {
        }
 
        luaL_getmetatable(L, NIXIO_FILE_META);
-       udata = lua_newuserdata(L, sizeof(FILE**));
+       udata = lua_newuserdata(L, sizeof(FILE*));
+       if (!udata) {
+               return luaL_error(L, "out of memory");
+       }
+
        if (!(*udata = fdopen(pipefd[0], "r"))) {
                return nixio__perror(L);
        }