[poppler] poppler/Object.cc poppler/Object.h

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Tue Sep 4 14:13:38 UTC 2018


 poppler/Object.cc |    8 ++------
 poppler/Object.h  |    9 +++++----
 2 files changed, 7 insertions(+), 10 deletions(-)

New commits:
commit f2223e12e401648a24d559ba766759b8afac2d5e
Author: Adam Reichold <adam.reichold at t-online.de>
Date:   Sun Sep 2 10:43:18 2018 +0200

    Assert validity of Object contents where at least constructor or destructor seem to assume it to catch errors as early as possible when using debug builds.

diff --git a/poppler/Object.cc b/poppler/Object.cc
index dc08b83f..9112d316 100644
--- a/poppler/Object.cc
+++ b/poppler/Object.cc
@@ -91,6 +91,7 @@ Object Object::copy() const {
     obj.string = string->copy();
     break;
   case objName:
+  case objCmd:
     obj.cString = copyString(cString);
     break;
   case objArray:
@@ -102,9 +103,6 @@ Object Object::copy() const {
   case objStream:
     stream->incRef();
     break;
-  case objCmd:
-    obj.cString = copyString(cString);
-    break;
   default:
     break;
   }
@@ -124,6 +122,7 @@ void Object::free() {
     delete string;
     break;
   case objName:
+  case objCmd:
     gfree(cString);
     break;
   case objArray:
@@ -141,9 +140,6 @@ void Object::free() {
       delete stream;
     }
     break;
-  case objCmd:
-    gfree(cString);
-    break;
   default:
     break;
   }
diff --git a/poppler/Object.h b/poppler/Object.h
index 15168214..5d11aec9 100644
--- a/poppler/Object.h
+++ b/poppler/Object.h
@@ -37,6 +37,7 @@
 #pragma interface
 #endif
 
+#include <cassert>
 #include <set>
 #include <stdio.h>
 #include <string.h>
@@ -156,15 +157,15 @@ public:
   explicit Object(GooString *stringA)
     { constructObj(objString); string = stringA; }
   Object(ObjType typeA, const char *stringA)
-    { constructObj(typeA); cString = copyString(stringA); }
+    { assert(typeA == objName || typeA == objCmd); assert(stringA); constructObj(typeA); cString = copyString(stringA); }
   explicit Object(long long int64gA)
     { constructObj(objInt64); int64g = int64gA; }
   explicit Object(Array *arrayA)
-    { constructObj(objArray); array = arrayA; }
+    { assert(arrayA); constructObj(objArray); array = arrayA; }
   explicit Object(Dict *dictA)
-    { constructObj(objDict); dict = dictA; }
+    { assert(dictA); constructObj(objDict); dict = dictA; }
   explicit Object(Stream *streamA)
-    { constructObj(objStream); stream = streamA; }
+    { assert(streamA); constructObj(objStream); stream = streamA; }
   Object(int numA, int genA)
     { constructObj(objRef); ref.num = numA; ref.gen = genA; }
   template<typename T> Object(T) = delete;


More information about the poppler mailing list