From 5f06552ba34c6bd3e4867e67acb452210157c57d Mon Sep 17 00:00:00 2001 From: Rhodri James Date: Mon, 15 May 2017 19:13:38 +0100 Subject: [PATCH] Comment why negative blocksize in poolGrow is hard to test Also add comment tags for lcov to ignore untestable code --- expat/lib/xmlparse.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/expat/lib/xmlparse.c b/expat/lib/xmlparse.c index e11e7ea2..65595eba 100644 --- a/expat/lib/xmlparse.c +++ b/expat/lib/xmlparse.c @@ -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; -- 2.49.0