From 4df8a2aedcf4234f3d8b6ac4ec2c733d6d829595 Mon Sep 17 00:00:00 2001 From: LDOUBLEV Date: Thu, 5 Aug 2021 06:05:51 +0000 Subject: [PATCH] fix cpp bug --- deploy/cpp_infer/src/config.cpp | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/deploy/cpp_infer/src/config.cpp b/deploy/cpp_infer/src/config.cpp index 303c3c12..050b75ed 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 -- GitLab