diff --git a/api/pdfrenderer.cpp b/api/pdfrenderer.cpp index 4acd9897a5..4d20bb3aee 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);