[libmath-prime-util-perl] 37/55: forpart edge cases

Partha P. Mukherjee ppm-guest at moszumanska.debian.org
Thu May 21 18:53:42 UTC 2015


This is an automated email from the git hooks/post-receive script.

ppm-guest pushed a commit to annotated tag v0.41
in repository libmath-prime-util-perl.

commit 87e369ee029cfc5f7cd1a77750aae82b2f854f98
Author: Dana Jacobsen <dana at acm.org>
Date:   Tue May 13 09:09:34 2014 -0700

    forpart edge cases
---
 XS.xs | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/XS.xs b/XS.xs
index 41bcd91..bb45b53 100644
--- a/XS.xs
+++ b/XS.xs
@@ -1275,6 +1275,7 @@ forpart (SV* block, IN SV* svn, IN SV* svh = 0)
       return;
     }
     n = my_svuv(svn);
+    if (n > (UV_MAX-2)) croak("forpart argument overflow");
 
     New(0, svals, n+1, SV*);
     for (i = 0; i <= n; i++) {
@@ -1302,7 +1303,7 @@ forpart (SV* block, IN SV* svn, IN SV* svh = 0)
 
     { /* ZS1 algorithm from Zoghbi and Stojmenovic 1998) */
       UV *x, m, h;
-      New(0, x, n+1, UV);
+      New(0, x, n+2, UV);  /* plus 2 because of n=0 */
       for(i = 2; i <= n; i++)  x[i] = 1;
       x[1] = n;
       m = (n > 0) ? 1 : 0;   /* n=0 => one call with empty list */

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-perl/packages/libmath-prime-util-perl.git



More information about the Pkg-perl-cvs-commits mailing list