summaryrefslogtreecommitdiff
path: root/hv.c
diff options
context:
space:
mode:
authorFather Chrysostomos <sprout@cpan.org>2011-09-24 06:29:10 -0700
committerFather Chrysostomos <sprout@cpan.org>2011-10-06 13:01:02 -0700
commitd35fec6c72b590957f6515638a64a6e4d0adddf8 (patch)
tree1757ffddbacf905ef632a7a15c66b3db9b93478a /hv.c
parent4643eb699312fbf71d4184f6fac9af209f2bfb50 (diff)
downloadperl-d35fec6c72b590957f6515638a64a6e4d0adddf8.tar.gz
Fix thinko in hek_eq_pvn_flags
Doing memEQ(str1, str2, len2) without checking the length first will cause memEQ("forth","fort"...) to compare equal and memEQ("fort","forth"...) to read unallocated memory. This was only a potential future problem, as none of the callers reach this branch.
Diffstat (limited to 'hv.c')
-rw-r--r--hv.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/hv.c b/hv.c
index a5a0f1affa..2004d3dcd0 100644
--- a/hv.c
+++ b/hv.c
@@ -2102,7 +2102,7 @@ hek_eq_pvn_flags(pTHX_ const HEK *hek, const char* pv, const I32 pvlen, const U3
(const U8*)HEK_KEY(hek), HEK_LEN(hek)) == 0);
}
else
- return ((HEK_KEY(hek) == pv)
+ return HEK_LEN(hek) == pvlen && ((HEK_KEY(hek) == pv)
|| memEQ(HEK_KEY(hek), pv, pvlen));
}