From 6be1a4707ff0b1cb1ea86e03f54d1d1e95233e7e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9gory=20Soutad=C3=A9?= Date: Mon, 14 Mar 2022 08:19:43 +0100 Subject: [PATCH] Be sure there is a final line return when writing streams data --- src/uPDFTypes.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/uPDFTypes.cpp b/src/uPDFTypes.cpp index acefc1e..90fe49b 100644 --- a/src/uPDFTypes.cpp +++ b/src/uPDFTypes.cpp @@ -106,6 +106,10 @@ namespace uPDFParser std::string res = "stream\n"; const char* streamData = (const char*)data(); // Force reading if not in memory res += std::string(streamData, _dataLength); + // Be sure there is a final line return + if (streamData[_dataLength-1] != '\n' && + streamData[_dataLength-1] != '\r') + res += "\n"; res += "endstream\n"; return res;