diff --git a/api/baseapi.cpp b/api/baseapi.cpp index 473df8a50..e1dec94c3 100644 --- a/api/baseapi.cpp +++ b/api/baseapi.cpp @@ -1757,8 +1757,8 @@ const int kLatinChs[] = { /** * The recognized text is returned as a char* which is coded - * as UNLV format Latin-1 with specific reject and suspect codes - * and must be freed with the delete [] operator. + * as UNLV format Latin-1 with specific reject and suspect codes. + * Returned string must be freed with the delete [] operator. */ char* TessBaseAPI::GetUNLVText() { if (tesseract_ == NULL || diff --git a/api/baseapi.h b/api/baseapi.h index 0b473e291..1efa76ba8 100644 --- a/api/baseapi.h +++ b/api/baseapi.h @@ -621,8 +621,8 @@ class TESS_API TessBaseAPI { /** * The recognized text is returned as a char* which is coded - * as UNLV format Latin-1 with specific reject and suspect codes - * and must be freed with the delete [] operator. + * as UNLV format Latin-1 with specific reject and suspect codes. + * Returned string must be freed with the delete [] operator. */ char* GetUNLVText(); diff --git a/api/renderer.cpp b/api/renderer.cpp index 2dc274da5..822e5244e 100644 --- a/api/renderer.cpp +++ b/api/renderer.cpp @@ -234,11 +234,10 @@ TessUnlvRenderer::TessUnlvRenderer(const char *outputbase) } bool TessUnlvRenderer::AddImageHandler(TessBaseAPI* api) { - char* unlv = api->GetUNLVText(); + const std::unique_ptr unlv(api->GetUNLVText()); if (unlv == NULL) return false; - AppendString(unlv); - delete[] unlv; + AppendString(unlv.get()); return true; }