[poppler] goo/PNGWriter.cc

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Thu Feb 2 23:01:14 UTC 2023


 goo/PNGWriter.cc |   24 ++++++++++++------------
 1 file changed, 12 insertions(+), 12 deletions(-)

New commits:
commit 329ec39cb876f0d4137eff4fbb5e4ce37601b71a
Author: Albert Astals Cid <aacid at kde.org>
Date:   Thu Feb 2 23:43:52 2023 +0100

    PngWriter: Fix uninitialized memory use
    
    When just created and deleted without having called init()

diff --git a/goo/PNGWriter.cc b/goo/PNGWriter.cc
index c3449ae6..92302ebe 100644
--- a/goo/PNGWriter.cc
+++ b/goo/PNGWriter.cc
@@ -29,23 +29,23 @@
 
 struct PNGWriterPrivate
 {
+    explicit PNGWriterPrivate(PNGWriter::Format f) : format(f) { }
+
     PNGWriter::Format format;
-    png_structp png_ptr;
-    png_infop info_ptr;
-    unsigned char *icc_data;
-    int icc_data_size;
-    char *icc_name;
-    bool sRGB_profile;
+    png_structp png_ptr = nullptr;
+    png_infop info_ptr = nullptr;
+    unsigned char *icc_data = nullptr;
+    int icc_data_size = 0;
+    char *icc_name = nullptr;
+    bool sRGB_profile = false;
+
+    PNGWriterPrivate(const PNGWriterPrivate &) = delete;
+    PNGWriterPrivate &operator=(const PNGWriterPrivate &) = delete;
 };
 
 PNGWriter::PNGWriter(Format formatA)
 {
-    priv = new PNGWriterPrivate;
-    priv->format = formatA;
-    priv->icc_data = nullptr;
-    priv->icc_data_size = 0;
-    priv->icc_name = nullptr;
-    priv->sRGB_profile = false;
+    priv = new PNGWriterPrivate(formatA);
 }
 
 PNGWriter::~PNGWriter()


More information about the poppler mailing list