[poppler] poppler/FlateEncoder.cc
GitLab Mirror
gitlab-mirror at kemper.freedesktop.org
Wed Nov 24 15:55:52 UTC 2021
poppler/FlateEncoder.cc | 12 +++++++++---
1 file changed, 9 insertions(+), 3 deletions(-)
New commits:
commit c702589307896c7d6f5f4cfdf63535761ad1ad23
Author: Even Rouault <even.rouault at spatialys.com>
Date: Wed Nov 24 16:14:24 2021 +0100
FlateEncoder.cc: fix -Wzero-as-null-pointer-constant warnings
Use nullptr instead of Z_NULL. zlib.h defines Z_NULL as 0, so using
nullptr is safe now, and for the future, as zlib.h can't really
change its definition to something that would be fundammentaly different
from expressing a null pointer.
diff --git a/poppler/FlateEncoder.cc b/poppler/FlateEncoder.cc
index 316e531e..fa8d574b 100644
--- a/poppler/FlateEncoder.cc
+++ b/poppler/FlateEncoder.cc
@@ -24,9 +24,15 @@ FlateEncoder::FlateEncoder(Stream *strA) : FilterStream(strA)
outBufPtr = outBufEnd = outBuf;
inBufEof = outBufEof = false;
- zlib_stream.zalloc = Z_NULL;
- zlib_stream.zfree = Z_NULL;
- zlib_stream.opaque = Z_NULL;
+ // We used to assign Z_NULL to the 3 following members of zlib_stream,
+ // but as Z_NULL is a #define to 0, using it triggers the
+ // -Wzero-as-null-pointer-constant warning.
+ // For safety, check that the Z_NULL definition is equivalent to
+ // 0 / null pointer.
+ static_assert(Z_NULL == 0);
+ zlib_stream.zalloc = nullptr;
+ zlib_stream.zfree = nullptr;
+ zlib_stream.opaque = nullptr;
zlib_status = deflateInit(&zlib_stream, Z_DEFAULT_COMPRESSION);
More information about the poppler
mailing list