fix: added protection against while-true condition in unbounded for loop

Signed-off-by: Jesse Simpson <jesse.simpson36@gmail.com>
pull/13586/head
Jesse Simpson 9 months ago
parent 6bb836374b
commit 487f72b822
No known key found for this signature in database
GPG Key ID: 237495C89AB0AAFC

@ -392,7 +392,7 @@ func determineIfFormattedErrorIsAcceptable(formattedErr error, originalErr error
if equivalenceRating >= 80 { if equivalenceRating >= 80 {
return formattedErr return formattedErr
} }
return originalErr return fmt.Errorf("%s", originalErr.Error())
} }
func cleanupExecError(filename string, err error) error { func cleanupExecError(filename string, err error) error {
@ -416,7 +416,8 @@ func cleanupExecError(filename string, err error) error {
} }
current := err current := err
fileLocations := []TraceableError{} fileLocations := []TraceableError{}
for { maxIterations := 100
for i := 0; i < maxIterations && current != nil; i++ {
if current == nil { if current == nil {
break break
} }
@ -429,6 +430,9 @@ func cleanupExecError(filename string, err error) error {
fileLocations = append(fileLocations, traceable) fileLocations = append(fileLocations, traceable)
current = errors.Unwrap(current) current = errors.Unwrap(current)
} }
if current != nil {
return fmt.Errorf("%s", err.Error())
}
prevMessage := "" prevMessage := ""
for i := len(fileLocations) - 1; i >= 0; i-- { for i := len(fileLocations) - 1; i >= 0; i-- {

Loading…
Cancel
Save