This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
caretx.c: Use inRANGE()
authorKarl Williamson <khw@cpan.org>
Thu, 3 Oct 2019 02:58:15 +0000 (20:58 -0600)
committerKarl Williamson <khw@cpan.org>
Thu, 26 Dec 2019 21:02:25 +0000 (14:02 -0700)
This is more efficient

caretx.c

index 247708d..fc5ff93 100644 (file)
--- a/caretx.c
+++ b/caretx.c
@@ -77,7 +77,7 @@ Perl_set_caret_X(pTHX) {
     mib[3] = -1;
 
     if (sysctl(mib, 4, NULL, &size, NULL, 0) == 0
-        && size > 0 && size < MAXPATHLEN * MAXPATHLEN) {
+        && inRANGE(size, 1, -1 + MAXPATHLEN * MAXPATHLEN)) {
         sv_grow(caret_x, size);
 
         if (sysctl(mib, 4, SvPVX(caret_x), &size, NULL, 0) == 0