diff options
author | Steven Barth <steven@midlink.org> | 2009-02-22 22:49:23 +0000 |
---|---|---|
committer | Steven Barth <steven@midlink.org> | 2009-02-22 22:49:23 +0000 |
commit | d2b11117f26285186b711271d24733d35e0444a1 (patch) | |
tree | 7c08cbd29658d0f0a1331f12156f5ddc97570975 /libs/nixio/src/file.c | |
parent | da6f427d818573f76dd50771f4d60ff693eb8fd9 (diff) |
NIXIO: TLS-Support, bugfixes
Diffstat (limited to 'libs/nixio/src/file.c')
-rw-r--r-- | libs/nixio/src/file.c | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/libs/nixio/src/file.c b/libs/nixio/src/file.c index 7b65abdc12..3333e23691 100644 --- a/libs/nixio/src/file.c +++ b/libs/nixio/src/file.c @@ -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); } |