utf8.h: Add assert for utf8n_to_uvchr_buf()
authorKarl Williamson <khw@cpan.org>
Mon, 11 Jun 2018 18:58:25 +0000 (12:58 -0600)
committerKarl Williamson <khw@cpan.org>
Mon, 2 Jul 2018 00:33:49 +0000 (18:33 -0600)
The Perl_utf8n_to_uvchr_buf() version of this function has an assert;
this adds it as well to the macro that bypasses the function.

utf8.h

diff --git a/utf8.h b/utf8.h
index e0fc6b6..87b26d1 100644 (file)
--- a/utf8.h
+++ b/utf8.h
@@ -74,8 +74,9 @@ the string is invariant.
 #define uvchr_to_utf8_flags_msgs(d,uv,flags,msgs)                              \
                 uvoffuni_to_utf8_flags_msgs(d,NATIVE_TO_UNI(uv),flags, msgs)
 #define utf8_to_uvchr_buf(s, e, lenp)                                          \
-                     utf8n_to_uvchr(s, (U8*)(e) - (U8*)(s), lenp,              \
-                                    ckWARN_d(WARN_UTF8) ? 0 : UTF8_ALLOW_ANY)
+                                (__ASSERT_((U8*) (e) > (U8*) (s))              \
+                                 utf8n_to_uvchr(s, (U8*)(e) - (U8*)(s), lenp,  \
+                                    ckWARN_d(WARN_UTF8) ? 0 : UTF8_ALLOW_ANY))
 #define utf8n_to_uvchr(s, len, lenp, flags)                                    \
                                 utf8n_to_uvchr_error(s, len, lenp, flags, 0)
 #define utf8n_to_uvchr_error(s, len, lenp, flags, errors)                      \