diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/lfs.c | 23 |
1 files changed, 12 insertions, 11 deletions
@@ -15,7 +15,7 @@ | |||
15 | ** lfs.touch (filepath [, atime [, mtime]]) | 15 | ** lfs.touch (filepath [, atime [, mtime]]) |
16 | ** lfs.unlock (fh) | 16 | ** lfs.unlock (fh) |
17 | ** | 17 | ** |
18 | ** $Id: lfs.c,v 1.43 2007/12/22 17:19:45 mascarenhas Exp $ | 18 | ** $Id: lfs.c,v 1.44 2008/01/16 22:29:26 mascarenhas Exp $ |
19 | */ | 19 | */ |
20 | 20 | ||
21 | #include <errno.h> | 21 | #include <errno.h> |
@@ -100,16 +100,17 @@ static int change_dir (lua_State *L) { | |||
100 | ** and a string describing the error | 100 | ** and a string describing the error |
101 | */ | 101 | */ |
102 | static int get_dir (lua_State *L) { | 102 | static int get_dir (lua_State *L) { |
103 | char path[255+2]; | 103 | char *path; |
104 | if (getcwd(path, 255) == NULL) { | 104 | if ((path = getcwd(NULL, 0)) == NULL) { |
105 | lua_pushnil(L); | 105 | lua_pushnil(L) |
106 | lua_pushstring(L, getcwd_error); | 106 | lua_pushstring(L, getcwd_error); |
107 | return 2; | 107 | return 2; |
108 | } | 108 | } |
109 | else { | 109 | else { |
110 | lua_pushstring(L, path); | 110 | lua_pushstring(L, path); |
111 | return 1; | 111 | free(path); |
112 | } | 112 | return 1; |
113 | } | ||
113 | } | 114 | } |
114 | 115 | ||
115 | /* | 116 | /* |