summaryrefslogtreecommitdiff
path: root/utf8.c
diff options
context:
space:
mode:
authorKarl Williamson <public@khwilliamson.com>2013-03-29 13:34:59 -0600
committerKarl Williamson <public@khwilliamson.com>2013-08-29 09:56:04 -0600
commit3d0f8846febc7f75124837422e1b33df546a714d (patch)
treecfd40afda1fdecc496cef50793e0ea2598f08c9d /utf8.c
parent56d37426a5bbcf5030800bc4d96e192cd673476b (diff)
downloadperl-3d0f8846febc7f75124837422e1b33df546a714d.tar.gz
utf8.c: No need to check for UTF-8 malformations
This function assumes that the input is well-formed UTF-8, even though until this commit, the prefatory comments didn't say so. The API does not pass the buffer length, so there is no way it could check for reading off the end of the buffer. One code path already calls valid_utf8_to_uvchr(); this changes the remaining code path to correspond.
Diffstat (limited to 'utf8.c')
-rw-r--r--utf8.c8
1 files changed, 3 insertions, 5 deletions
diff --git a/utf8.c b/utf8.c
index 0d1e8c90f9..e7cca972a6 100644
--- a/utf8.c
+++ b/utf8.c
@@ -3118,8 +3118,8 @@ Perl__core_swash_init(pTHX_ const char* pkg, const char* name, SV *listsv, I32 m
/* Note:
* Returns the value of property/mapping C<swash> for the first character
* of the string C<ptr>. If C<do_utf8> is true, the string C<ptr> is
- * assumed to be in utf8. If C<do_utf8> is false, the string C<ptr> is
- * assumed to be in native 8-bit encoding. Caches the swatch in C<swash>.
+ * assumed to be in well-formed utf8. If C<do_utf8> is false, the string C<ptr>
+ * is assumed to be in native 8-bit encoding. Caches the swatch in C<swash>.
*
* A "swash" is a hash which contains initially the keys/values set up by
* SWASHNEW. The purpose is to be able to completely represent a Unicode
@@ -3224,9 +3224,7 @@ Perl_swash_fetch(pTHX_ SV *swash, const U8 *ptr, bool do_utf8)
/* If not cached, generate it via swatch_get */
if (!svp || !SvPOK(*svp)
|| !(tmps = (const U8*)SvPV_const(*svp, slen))) {
- const UV code_point = utf8n_to_uvchr(ptr, UTF8_MAXBYTES, 0,
- ckWARN(WARN_UTF8) ?
- 0 : UTF8_ALLOW_ANY);
+ const UV code_point = valid_utf8_to_uvchr(ptr, NULL);
swatch = swatch_get(swash,
/* On EBCDIC & ~(0xA0-1) isn't a useful thing to do */
(klen) ? (code_point & ~((UV)needents - 1)) : 0,