diff --git a/deploy/cpp_infer/src/config.cpp b/deploy/cpp_infer/src/config.cpp index 303c3c1259515ee8c67fa865bf485ae3338505d6..050b75ede9475432f250cafac2cd5fbed17fea0a 100644 --- a/deploy/cpp_infer/src/config.cpp +++ b/deploy/cpp_infer/src/config.cpp @@ -21,12 +21,18 @@ std::vector OCRConfig::split(const std::string &str, std::vector res; if ("" == str) return res; - char *strs = new char[str.length() + 1]; + + int strlen = str.length() + 1; + chars *strs = new char[strlen]; std::strcpy(strs, str.c_str()); - char *d = new char[delim.length() + 1]; + int delimlen = delim.length() + 1; + char *d = new char[delimlen]; std::strcpy(d, delim.c_str()); + delete[] strs; + delete[] d; + char *p = std::strtok(strs, d); while (p) { std::string s = p; @@ -61,4 +67,4 @@ void OCRConfig::PrintConfigInfo() { std::cout << "=======End of Paddle OCR inference config======" << std::endl; } -} // namespace PaddleOCR \ No newline at end of file +} // namespace PaddleOCR