From d8a55d739dda4640c7d5e4baf990e2aa59c6a783 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zdenko=20Podobn=C3=BD?= Date: Fri, 22 May 2015 21:17:33 +0200 Subject: [PATCH] Fix potential null pointer dereference in ccmain/paragraphs.cpp. --- api/pdfrenderer.cpp | 6 +++++- ccmain/paragraphs.cpp | 7 +++++-- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/api/pdfrenderer.cpp b/api/pdfrenderer.cpp index 4acd9897a..4d20bb3ae 100644 --- a/api/pdfrenderer.cpp +++ b/api/pdfrenderer.cpp @@ -636,7 +636,11 @@ bool TessPDFRenderer::BeginDocumentHandler() { " /Length1 %ld\n" ">>\n" "stream\n", size, size); - if (n >= sizeof(buf)) return false; + if (n >= sizeof(buf)) + { + delete[] buffer; + return false; + } AppendString(buf); objsize = strlen(buf); AppendData(buffer, size); diff --git a/ccmain/paragraphs.cpp b/ccmain/paragraphs.cpp index 17f2d7399..a36364c34 100644 --- a/ccmain/paragraphs.cpp +++ b/ccmain/paragraphs.cpp @@ -2400,8 +2400,11 @@ void InitializeTextAndBoxesPreRecognition(const MutableIterator &it, } word_res = page_res_it.forward(); } while (page_res_it.row() == this_row); - info->lword_box = lword->word->bounding_box(); - info->rword_box = rword->word->bounding_box(); + + if(lword) + info->lword_box = lword->word->bounding_box(); + if(rword) + info->rword_box = rword->word->bounding_box(); }