diff --git a/src/utils.cpp b/src/utils.cpp index 8e1b348..f9cf0d7 100644 --- a/src/utils.cpp +++ b/src/utils.cpp @@ -2,6 +2,7 @@ #include #include +#include #include #include #include @@ -59,10 +60,11 @@ ssize_t readFile2(std::string path, char* buffer, size_t maxlen) { } std::string readFile(std::string path, size_t trim) { - char buf[trim + 2]; + char* buf = new char[trim + 2]; ssize_t len = readFile2(path, buf, trim + 2); - if (!len) return "0"; std::string out(buf); + delete[] buf; + if (!len) return "0"; return out.substr(0, len - 1); }