[ 
https://issues.apache.org/jira/browse/GROOVY-7902?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Felipe Mamud updated GROOVY-7902:
---------------------------------
    Description: 
Fixing infinite loop in Iterable.collate method when step parameter is equals 
to zero.

Example:

{code:groovy}
[ 1, 2, 3 ].collate( 2, 0 )
{code}

The result is a infinite loop because the step parameter is used directly in 
the for increment: pos += step

In the fixing I assumed that the step parameter should be equals to size 
parameter, looks like in the collate(self, size, size, keepRemainder) 
overloaded method, with absence of step and I considered backward compatibility 
with negative steps.

PR opened in Github: https://github.com/apache/groovy/pull/378

Thks.
Felipe Mamud

  was:
Fixing infinite loop in Iterable.collate method when step parameter is equals 
to zero.

Example:

[ 1, 2, 3 ].collate( 2, 0 )

The result is a infinite loop because the step parameter is used directly in 
the for increment: pos += step

In the fixing I assumed that the step parameter should be equals to size 
parameter, looks like in the collate(self, size, size, keepRemainder) 
overloaded method, with absence of step and I considered backward compatibility 
with negative steps.

PR opened in Github: https://github.com/apache/groovy/pull/378

Thks.
Felipe Mamud


> collate() infinite loop with zeroed step
> ----------------------------------------
>
>                 Key: GROOVY-7902
>                 URL: https://issues.apache.org/jira/browse/GROOVY-7902
>             Project: Groovy
>          Issue Type: Bug
>          Components: groovy-jdk, groovy-runtime
>    Affects Versions: 2.4.7
>         Environment: Groovy Version: 2.4.7 JVM: 1.8.0_92 Vendor: Oracle 
> Corporation OS: Mac OS X
>            Reporter: Felipe Mamud
>            Priority: Minor
>
> Fixing infinite loop in Iterable.collate method when step parameter is equals 
> to zero.
> Example:
> {code:groovy}
> [ 1, 2, 3 ].collate( 2, 0 )
> {code}
> The result is a infinite loop because the step parameter is used directly in 
> the for increment: pos += step
> In the fixing I assumed that the step parameter should be equals to size 
> parameter, looks like in the collate(self, size, size, keepRemainder) 
> overloaded method, with absence of step and I considered backward 
> compatibility with negative steps.
> PR opened in Github: https://github.com/apache/groovy/pull/378
> Thks.
> Felipe Mamud



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to