From: Zachary Snow Date: Mon, 14 Jun 2021 15:59:01 +0000 (-0400) Subject: macos: fix leak in proc_self_dirname() X-Git-Tag: yosys-0.10~138 X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=b516c681fe6c06fb089fe1e1bc081ffeb56c7949;p=yosys.git macos: fix leak in proc_self_dirname() --- diff --git a/kernel/yosys.cc b/kernel/yosys.cc index efc429529..cb6fdc2f4 100644 --- a/kernel/yosys.cc +++ b/kernel/yosys.cc @@ -797,7 +797,9 @@ std::string proc_self_dirname() path = (char *) realloc((void *) path, buflen); while (buflen > 0 && path[buflen-1] != '/') buflen--; - return std::string(path, buflen); + std::string str(path, buflen); + free(path); + return str; } #elif defined(_WIN32) std::string proc_self_dirname()