[poppler] 2 commits - goo/gmem.h goo/NetPBMWriter.h

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Thu May 12 20:46:01 UTC 2022


 goo/NetPBMWriter.h |    2 +-
 goo/gmem.h         |    4 +++-
 2 files changed, 4 insertions(+), 2 deletions(-)

New commits:
commit 4eeb3380ea77d277ace735f191f303564a25a0e3
Author: Albert Astals Cid <aacid at kde.org>
Date:   Thu May 12 22:42:02 2022 +0200

    greallocn: Make gcc 12.1 happier
    
    Without this hint that bytes is always going to be > 0 we got a million
    of warnings like
    
    In function ‘void gfree(void*)’,
        inlined from ‘void* greallocn(void*, int, int, bool, bool)’ at goo/gmem.h:178:14,
        inlined from ‘void CharCodeToUnicode::setMapping(CharCode, Unicode*, int)’ at poppler/CharCodeToUnicode.cc:648:60:
    goo/gmem.h:65:14: warning: pointer used after ‘void free(void*)’ [-Wuse-after-free]
       65 |     std::free(p);
          |     ~~~~~~~~~^~~
    In function ‘void gfree(void*)’,
        inlined from ‘void* grealloc(void*, size_t, bool)’ at goo/gmem.h:73:14,
        inlined from ‘void* greallocn(void*, int, int, bool, bool)’ at goo/gmem.h:174:27,
        inlined from ‘void CharCodeToUnicode::setMapping(CharCode, Unicode*, int)’ at poppler/CharCodeToUnicode.cc:648:60:
    goo/gmem.h:65:14: note: call to ‘void free(void*)’ here
       65 |     std::free(p);
          |     ~~~~~~~~~^~~

diff --git a/goo/gmem.h b/goo/gmem.h
index 5d5fb1ec..100c9b36 100644
--- a/goo/gmem.h
+++ b/goo/gmem.h
@@ -14,7 +14,7 @@
 // under GPL version 2 or later
 //
 // Copyright (C) 2005 Takashi Iwai <tiwai at suse.de>
-// Copyright (C) 2007-2010, 2017, 2019 Albert Astals Cid <aacid at kde.org>
+// Copyright (C) 2007-2010, 2017, 2019, 2022 Albert Astals Cid <aacid at kde.org>
 // Copyright (C) 2008 Jonathan Kew <jonathan_kew at sil.org>
 // Copyright (C) 2018 Adam Reichold <adam.reichold at t-online.de>
 // Copyright (C) 2021 Even Rouault <even.rouault at spatialys.com>
@@ -27,6 +27,7 @@
 #ifndef GMEM_H
 #define GMEM_H
 
+#include <cassert>
 #include <cstring>
 #include <cstdlib>
 #include <cstdio>
@@ -169,6 +170,7 @@ inline void *greallocn(void *p, int count, int size, bool checkoverflow = false,
         std::abort();
     }
 
+    assert(bytes > 0);
     if (void *q = grealloc(p, bytes, checkoverflow)) {
         return q;
     }
commit e7f0fd89d937d28a77539fb9782a2b59eb51e5a8
Author: Albert Astals Cid <aacid at kde.org>
Date:   Thu May 12 22:38:40 2022 +0200

    NetPBMWriter: Change destructor
    
    Makes gcc 12.1 happier, i think it was a gcc bug anyway, but the new
    code is a bit "better" anyway, the warning i was getting is
    
    In file included from utils/ImageOutputDev.cc:44:
    In destructor ‘virtual NetPBMWriter::~NetPBMWriter()’,
        inlined from ‘virtual NetPBMWriter::~NetPBMWriter()’ at goo/NetPBMWriter.h:41:31,
        inlined from ‘void ImageOutputDev::writeImage(GfxState*, Object*, Stream*, int, int, GfxImageColorMap*, bool)’ at utils/ImageOutputDev.cc:636:16:
    goo/NetPBMWriter.h:41:31: warning: array subscript ‘NetPBMWriter[0]’ is partly outside array bounds of ‘ImgWriter [2]’ [-Warray-bounds]
       41 |     ~NetPBMWriter() override {};
          |                               ^
    utils/ImageOutputDev.cc: In member function ‘void ImageOutputDev::writeImage(GfxState*, Object*, Stream*, int, int, GfxImageColorMap*, bool)’:
    utils/ImageOutputDev.cc:620:57: note: object of size 16 allocated by ‘operator new’
      620 |             writer = new PNGWriter(PNGWriter::MONOCHROME);
          |                                                         ^
    utils/ImageOutputDev.cc:623:51: note: object of size 16 allocated by ‘operator new’
      623 |             writer = new PNGWriter(PNGWriter::GRAY);
          |                                                   ^
    utils/ImageOutputDev.cc:627:52: note: object of size 16 allocated by ‘operator new’
      627 |             writer = new PNGWriter(PNGWriter::RGB48);
          |                                                    ^
    utils/ImageOutputDev.cc:630:50: note: object of size 16 allocated by ‘operator new’
      630 |             writer = new PNGWriter(PNGWriter::RGB);
          |                                                  ^

diff --git a/goo/NetPBMWriter.h b/goo/NetPBMWriter.h
index 3075d730..a942a574 100644
--- a/goo/NetPBMWriter.h
+++ b/goo/NetPBMWriter.h
@@ -38,7 +38,7 @@ public:
     };
 
     explicit NetPBMWriter(Format formatA = RGB);
-    ~NetPBMWriter() override {};
+    ~NetPBMWriter() override = default;
 
     bool init(FILE *f, int width, int height, double /*hDPI*/, double /*vDPI*/) override;
 


More information about the poppler mailing list