-
Notifications
You must be signed in to change notification settings - Fork 16
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix infinite loop #5
Conversation
Could you give me an example to reproduce the issue? |
Sure
package main
import (
"log"
debver "github.com/knqyf263/go-deb-version"
)
func main() {
from := "1.12+git+1+e37ca00-0.3"
to := "1.12+git+1+e37ca0"
verFrom, err := debver.NewVersion(from)
if err != nil {
log.Fatal(err)
}
verTo, err := debver.NewVersion(to)
if err != nil {
log.Fatalln(err)
}
result := verFrom.Compare(verTo)
log.Println(result)
}
…On Thu, Mar 10, 2022 at 5:44 PM Teppei Fukuda ***@***.***> wrote:
Could you give me an example to reproduce the issue?
—
Reply to this email directly, view it on GitHub
<#5 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AEWFI56KREJQ5QJKKVQSODDU7IKEFANCNFSM5QC6NDQQ>
.
You are receiving this because you authored the thread.Message ID:
***@***.***>
--
Regards,
Ionut Andriescu
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry for the late reply. Could you add a test case to replicate this issue?
var index int | ||
c1 := len(strings1) | ||
c2 := len(strings2) | ||
if c1 >= c2 { | ||
index = c1 | ||
} else { | ||
index = c2 | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What if comparing numbers1 with numbers2, and strings1 with strings2?
var index int | |
c1 := len(strings1) | |
c2 := len(strings2) | |
if c1 >= c2 { | |
index = c1 | |
} else { | |
index = c2 | |
} | |
if reflect.DeepEqual(numbers1, numbers2) && reflect.DeepEqual(strings1, strings2) { | |
return 0 | |
} |
var index int | ||
c1 := len(s1) | ||
c2 := len(s2) | ||
if c1 >= c2 { | ||
index = c1 | ||
} else { | ||
index = c2 | ||
} | ||
|
||
for i := 0; i < index; i++ { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are you sure we need them? if s1 == s2 {}
prevents infinite loops, I think.
Hi @knqyf263 |
Signed-off-by: knqyf263 <[email protected]>
Issue #, if available:
Description of changes:
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.