diff options
author | Albert Astals Cid <aacid@kde.org> | 2023-02-02 23:43:52 +0100 |
---|---|---|
committer | Albert Astals Cid <aacid@kde.org> | 2023-02-02 23:58:09 +0100 |
commit | 329ec39cb876f0d4137eff4fbb5e4ce37601b71a (patch) | |
tree | 0818b2caa75f9be7ec3f47dd38edecaf530bb65f | |
parent | 7673e1fd712416a5d65406d7447a1c3d5ada057b (diff) |
PngWriter: Fix uninitialized memory use
When just created and deleted without having called init()
-rw-r--r-- | goo/PNGWriter.cc | 24 |
1 files changed, 12 insertions, 12 deletions
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() |