From 809bbd9bfa0e3123ca81f2341fab37b130bac9d2 Mon Sep 17 00:00:00 2001 From: Tom Morris Date: Wed, 17 Feb 2016 10:20:18 -0500 Subject: [PATCH] Fix varsize array for Microsoft compiler --- api/baseapi.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/api/baseapi.cpp b/api/baseapi.cpp index cd6985da8e..7a479f60fc 100644 --- a/api/baseapi.cpp +++ b/api/baseapi.cpp @@ -1379,14 +1379,14 @@ static void AddBaselineCoordsTohOCR(const PageIterator *it, } static void AddIdTohOCR(STRING* hocr_str, const std::string base, int num1, int num2) { - unsigned long bufsize = base.length() + 2 * kMaxIntSize; - char id_buffer[bufsize]; + const unsigned long BUFSIZE = 64; + char id_buffer[BUFSIZE]; if (num2 >= 0) { - snprintf(id_buffer, bufsize - 1, "%s_%d_%d", base.c_str(), num1, num2); + snprintf(id_buffer, BUFSIZE - 1, "%s_%d_%d", base.c_str(), num1, num2); } else { - snprintf(id_buffer, bufsize - 1, "%s_%d", base.c_str(), num1); + snprintf(id_buffer, BUFSIZE - 1, "%s_%d", base.c_str(), num1); } - id_buffer[bufsize - 1] = '\0'; + id_buffer[BUFSIZE - 1] = '\0'; *hocr_str += " id='"; *hocr_str += id_buffer; *hocr_str += "'";