]> granicus.if.org Git - libexpat/commitdiff
Comment why negative blocksize in poolGrow is hard to test
authorRhodri James <rhodri@kynesim.co.uk>
Mon, 15 May 2017 18:13:38 +0000 (19:13 +0100)
committerSebastian Pipping <sebastian@pipping.org>
Sat, 22 Jul 2017 20:49:16 +0000 (22:49 +0200)
Also add comment tags for lcov to ignore untestable code

expat/lib/xmlparse.c

index e11e7ea21bb4105e98ee3f0b6db1eaa34899fd8c..65595eba0e4fca54cbfec0e34d9f56e8e8ac8639 100644 (file)
@@ -6966,8 +6966,18 @@ poolGrow(STRING_POOL *pool)
     int blockSize = (int)(pool->end - pool->start);
     size_t bytesToAllocate;
 
-    if (blockSize < 0)
-      return XML_FALSE;
+    if (blockSize < 0) {
+      /* This condition traps a situation where either more than
+       * INT_MAX bytes have already been allocated (which is prevented
+       * by various pieces of program logic, not least this one, never
+       * mind the unlikelihood of actually having that much memory) or
+       * the pool control fields have been corrupted (which could
+       * conceivably happen in an extremely buggy user handler
+       * function).  Either way it isn't readily testable, so we
+       * exclude it from the coverage statistics.
+       */
+      return XML_FALSE;  /* LCOV_EXCL_LINE */
+    }
 
     if (blockSize < INIT_BLOCK_SIZE)
       blockSize = INIT_BLOCK_SIZE;