summaryrefslogtreecommitdiff
path: root/ext/Storable
diff options
context:
space:
mode:
authorNicholas Clark <nick@ccl4.org>2006-04-15 21:43:13 +0000
committerNicholas Clark <nick@ccl4.org>2006-04-15 21:43:13 +0000
commit0d3260984663aa39a4c25834f566132d81a03c27 (patch)
treee77014bd5e7094ea247881ae36f25596aaa2df7c /ext/Storable
parent5860085a49b592c6a586022a93b99a5b2e2d24a5 (diff)
downloadperl-0d3260984663aa39a4c25834f566132d81a03c27.tar.gz
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
Diffstat (limited to 'ext/Storable')
-rw-r--r--ext/Storable/Storable.xs6
1 files changed, 5 insertions, 1 deletions
diff --git a/ext/Storable/Storable.xs b/ext/Storable/Storable.xs
index 84d76aa2fb..a8beda151d 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 */
}