macos: fix leak in proc_self_dirname()

This commit is contained in:
Zachary Snow 2021-06-14 11:59:01 -04:00 committed by Zachary Snow
parent 081111714e
commit b516c681fe
1 changed files with 3 additions and 1 deletions

View File

@ -797,7 +797,9 @@ std::string proc_self_dirname()
path = (char *) realloc((void *) path, buflen); path = (char *) realloc((void *) path, buflen);
while (buflen > 0 && path[buflen-1] != '/') while (buflen > 0 && path[buflen-1] != '/')
buflen--; buflen--;
return std::string(path, buflen); std::string str(path, buflen);
free(path);
return str;
} }
#elif defined(_WIN32) #elif defined(_WIN32)
std::string proc_self_dirname() std::string proc_self_dirname()