From bdd2fe77dd8bf63afe74f55fe85c59da613b0589 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Robert=20P=C3=B6sel?= Date: Thu, 11 May 2017 03:06:03 +0200 Subject: [PATCH] Fix size of string holding symbol and confidence We're printing "%s|%.2f" which could end up in "%s|100.00" so it's "strlen(utfText) + 7". --- .../jni/com_googlecode_tesseract_android/resultiterator.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tess-two/jni/com_googlecode_tesseract_android/resultiterator.cpp b/tess-two/jni/com_googlecode_tesseract_android/resultiterator.cpp index 4b71ceb08..dc4d1bc18 100644 --- a/tess-two/jni/com_googlecode_tesseract_android/resultiterator.cpp +++ b/tess-two/jni/com_googlecode_tesseract_android/resultiterator.cpp @@ -72,7 +72,7 @@ jobjectArray Java_com_googlecode_tesseract_android_ResultIterator_nativeGetSymbo const char *utfText = cb.GetUTF8Text(); // Add each string to the object array elements - char newString[strlen(utfText) + 5]; + char newString[strlen(utfText) + 7]; sprintf(newString, "%s|%.2f", utfText, cb.Confidence()); env->SetObjectArrayElement(ret, i, env->NewStringUTF(newString));