fix off-by-one error in key detection logic for uninitialized warnings
authorYves Orton <demerphq@gmail.com>
Sat, 20 Oct 2012 12:54:09 +0000 (14:54 +0200)
committerYves Orton <demerphq@gmail.com>
Sat, 20 Oct 2012 12:54:09 +0000 (14:54 +0200)
Prior to this patch we would not look at the 0th bucket.

sv.c
t/lib/warnings/9uninit

diff --git a/sv.c b/sv.c
index f728516..9f9ef1c 100644 (file)
--- a/sv.c
+++ b/sv.c
@@ -13836,7 +13836,7 @@ S_find_hash_subscript(pTHX_ const HV *const hv, const SV *const val)
 
     array = HvARRAY(hv);
 
-    for (i=HvMAX(hv); i>0; i--) {
+    for (i=HvMAX(hv); i>=0; i--) {
        HE *entry;
        for (entry = array[i]; entry; entry = HeNEXT(entry)) {
            if (HeVAL(entry) != val)
index db5c634..781d1fa 100644 (file)
@@ -2043,7 +2043,6 @@ write;
 EXPECT
 Use of uninitialized value $x in string at - line 6.
 ########
-# TODO bugfix will come next patch
 # NAME off-by-one error in hash bucket walk in key detection logic
 use warnings 'uninitialized';