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);
}
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);
}