summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Drahoš <drahosp@gmail.com>2013-12-08 14:51:09 +0100
committerPeter Drahoš <drahosp@gmail.com>2013-12-08 14:51:09 +0100
commita77a47e2f059c0285bbc339fa080ee1c1b144710 (patch)
treecd57782859c88f978afd912edcbd663b53f1ae3d
parent0937bc974bbf0c062a222ffa49fa20c7cc6ab357 (diff)
downloadlua-a77a47e2f059c0285bbc339fa080ee1c1b144710.tar.gz
Memory leak fix
-rw-r--r--src/loadlib_rel.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/src/loadlib_rel.c b/src/loadlib_rel.c
index ea9f044..0556ba9 100644
--- a/src/loadlib_rel.c
+++ b/src/loadlib_rel.c
@@ -75,7 +75,7 @@ static void setprogdir(lua_State *L) {
char progdir[_PATH_MAX + 1];
char *lb;
int nsize = sizeof(progdir)/sizeof(char);
- int n;
+ int n = 0;
#if defined(__CYGWIN__)
char win_buff[_PATH_MAX + 1];
GetModuleFileNameA(NULL, win_buff, nsize);
@@ -120,6 +120,7 @@ static void setprogdir(lua_State *L) {
sprintf(cmd, "lsof -p %d | awk '{if ($5==\"REG\") { print $9 ; exit}}' 2> /dev/null", pid);
fd = popen(cmd, "r");
n = fread(progdir, 1, nsize, fd);
+ pclose(fd);
// remove newline
if (n > 1) progdir[--n] = '\0';