Fix varsize array for Microsoft compiler

This commit is contained in:
Tom Morris 2016-02-17 10:20:18 -05:00 committed by Zdenko Podobný
parent 473c30fa87
commit c3ad0de69b

View File

@ -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 += "'";