[poppler] 2 commits - poppler/DCTStream.cc poppler/JPEG2000Stream.cc
GitLab Mirror
gitlab-mirror at kemper.freedesktop.org
Fri Apr 1 21:53:46 UTC 2022
poppler/DCTStream.cc | 6 +++---
poppler/JPEG2000Stream.cc | 14 +++++---------
2 files changed, 8 insertions(+), 12 deletions(-)
New commits:
commit deb36a4e808a08b990413bf688acd72cc007aa45
Author: Albert Astals Cid <aacid at kde.org>
Date: Fri Apr 1 23:47:08 2022 +0200
Make MSVC happy
limit is always > than current
and after the if we know that left is < nChars
diff --git a/poppler/DCTStream.cc b/poppler/DCTStream.cc
index 6034b733..48dbb6d7 100644
--- a/poppler/DCTStream.cc
+++ b/poppler/DCTStream.cc
@@ -5,7 +5,7 @@
// This file is licensed under the GPLv2 or later
//
// Copyright 2005 Jeff Muizelaar <jeff at infidigm.net>
-// Copyright 2005-2010, 2012, 2017, 2020, 2021 Albert Astals Cid <aacid at kde.org>
+// Copyright 2005-2010, 2012, 2017, 2020-2022 Albert Astals Cid <aacid at kde.org>
// Copyright 2009 Ryszard Trojnacki <rysiek at menel.com>
// Copyright 2010 Carlos Garcia Campos <carlosgc at gnome.org>
// Copyright 2011 Daiki Ueno <ueno at unixuser.org>
@@ -227,12 +227,12 @@ int DCTStream::getChars(int nChars, unsigned char *buffer)
return i;
}
}
- int left = limit - current;
+ intptr_t left = limit - current;
if (left + i > nChars) {
left = nChars - i;
}
memcpy(buffer + i, current, left);
- current += left;
+ current += static_cast<int>(left);
i += left;
}
return nChars;
commit 1e9e4619671a14ff3d137f013f04f7e6904c5d2e
Author: Albert Astals Cid <aacid at kde.org>
Date: Fri Apr 1 23:43:12 2022 +0200
JPEG2000Stream: Some wrangling with the data types
I think this is more correct, and also makes MSVC happier
diff --git a/poppler/JPEG2000Stream.cc b/poppler/JPEG2000Stream.cc
index 5dd7c3dd..2b9e4474 100644
--- a/poppler/JPEG2000Stream.cc
+++ b/poppler/JPEG2000Stream.cc
@@ -4,7 +4,7 @@
//
// A JPX stream decoder using OpenJPEG
//
-// Copyright 2008-2010, 2012, 2017-2021 Albert Astals Cid <aacid at kde.org>
+// Copyright 2008-2010, 2012, 2017-2022 Albert Astals Cid <aacid at kde.org>
// Copyright 2011 Daniel Glöckner <daniel-gl at gmx.net>
// Copyright 2014, 2016 Thomas Freitag <Thomas.Freitag at alfa.de>
// Copyright 2013, 2014 Adrian Johnson <ajohnson at redneon.com>
@@ -201,7 +201,7 @@ typedef struct JPXData_s
{
const unsigned char *data;
int size;
- int pos;
+ OPJ_OFF_T pos;
} JPXData;
#define BUFFER_INITIAL_SIZE 4096
@@ -209,16 +209,12 @@ typedef struct JPXData_s
static OPJ_SIZE_T jpxRead_callback(void *p_buffer, OPJ_SIZE_T p_nb_bytes, void *p_user_data)
{
JPXData *jpxData = (JPXData *)p_user_data;
- int len;
- len = jpxData->size - jpxData->pos;
- if (len < 0) {
- len = 0;
- }
- if (len == 0) {
+ if (unlikely(jpxData->size <= jpxData->pos)) {
return (OPJ_SIZE_T)-1; /* End of file! */
}
- if ((OPJ_SIZE_T)len > p_nb_bytes) {
+ OPJ_SIZE_T len = jpxData->size - jpxData->pos;
+ if (len > p_nb_bytes) {
len = p_nb_bytes;
}
memcpy(p_buffer, jpxData->data + jpxData->pos, len);
More information about the poppler
mailing list