diff --git a/Util/BacktraceException.hpp b/Util/BacktraceException.hpp index a0ed2d017..313efb834 100644 --- a/Util/BacktraceException.hpp +++ b/Util/BacktraceException.hpp @@ -18,6 +18,14 @@ namespace Util { * deferred until `what()` is called on the handled exception. */ +struct PcloseDeleter { + void operator()(FILE* fp) const { + if (fp) { + pclose(fp); + } + } +}; + template class BacktraceException : public T { public: @@ -76,7 +84,7 @@ class BacktraceException : public T { std::array buffer; std::string result; - std::unique_ptr pipe(popen(cmd, "r"), pclose); + std::unique_ptr pipe(popen(cmd, "r")); if (!pipe) { return " -- error: unable to open addr2line";