From: Nicholas Clark Date: Sat, 15 Apr 2006 21:43:13 +0000 (+0000) Subject: Coverity reports that Storable can potentially cause a NULL pointer X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=0d3260984663aa39a4c25834f566132d81a03c27;p=p5sagit%2Fp5-mst-13.2.git Coverity reports that Storable can potentially cause a NULL pointer dereference while iterating a hash. This should never happen unless the hash lies about how many keys it has, so croak if a fib is spotted. p4raw-id: //depot/perl@27825 --- diff --git a/ext/Storable/Storable.xs b/ext/Storable/Storable.xs index 84d76aa..a8beda1 100644 --- a/ext/Storable/Storable.xs +++ b/ext/Storable/Storable.xs @@ -2329,7 +2329,11 @@ static int store_hash(pTHX_ stcxt_t *cxt, HV *hv) #else HE *he = hv_iternext(hv); #endif - SV *key = hv_iterkeysv(he); + SV *key; + + if (!he) + CROAK(("Hash %p inconsistent - expected %d keys, %dth is NULL", hv, len, i)); + key = hv_iterkeysv(he); av_store(av, AvFILLp(av)+1, key); /* av_push(), really */ }