aboutsummaryrefslogtreecommitdiff
path: root/src/lpm.c
diff options
context:
space:
mode:
authorAdam Harrison <adamdharrison@gmail.com>2023-05-22 13:47:55 -0400
committerAdam Harrison <adamdharrison@gmail.com>2023-05-22 13:47:55 -0400
commit9d2e02a6f7191036b3d6f1db8858ded619693b06 (patch)
treedbbf16874f318b37e630a1658ec29cfaf4914fb9 /src/lpm.c
parent828b9e8f96d0e14f1e39f09cce1def3fdf698e46 (diff)
downloadlite-xl-plugin-manager-9d2e02a6f7191036b3d6f1db8858ded619693b06.tar.gz
lite-xl-plugin-manager-9d2e02a6f7191036b3d6f1db8858ded619693b06.zip
Fixed a no-free error memory leak.
Diffstat (limited to 'src/lpm.c')
-rw-r--r--src/lpm.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/src/lpm.c b/src/lpm.c
index a21e11f..163c7b0 100644
--- a/src/lpm.c
+++ b/src/lpm.c
@@ -242,7 +242,7 @@ static int lpm_stat(lua_State *L) {
#else
struct stat s;
int err = lstat(path, &s);
- const char *abs_path = realpath(path, NULL);
+ const char *abs_path = !err ? realpath(path, NULL) : NULL;
#endif
if (err || !abs_path) {
lua_pushnil(L);
@@ -251,6 +251,7 @@ static int lpm_stat(lua_State *L) {
}
lua_newtable(L);
lua_pushstring(L, abs_path); lua_setfield(L, -2, "abs_path");
+ free((char*)abs_path);
lua_pushvalue(L, 1); lua_setfield(L, -2, "path");
#if __linux__