Skip to content
This repository was archived by the owner on Nov 20, 2020. It is now read-only.

Commit a77a47e

Browse files
committed
Memory leak fix
1 parent 0937bc9 commit a77a47e

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

src/loadlib_rel.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ static void setprogdir(lua_State *L) {
7575
char progdir[_PATH_MAX + 1];
7676
char *lb;
7777
int nsize = sizeof(progdir)/sizeof(char);
78-
int n;
78+
int n = 0;
7979
#if defined(__CYGWIN__)
8080
char win_buff[_PATH_MAX + 1];
8181
GetModuleFileNameA(NULL, win_buff, nsize);
@@ -120,6 +120,7 @@ static void setprogdir(lua_State *L) {
120120
sprintf(cmd, "lsof -p %d | awk '{if ($5==\"REG\") { print $9 ; exit}}' 2> /dev/null", pid);
121121
fd = popen(cmd, "r");
122122
n = fread(progdir, 1, nsize, fd);
123+
pclose(fd);
123124

124125
// remove newline
125126
if (n > 1) progdir[--n] = '\0';

0 commit comments

Comments
 (0)