fix podman network inspect index check#12756
Conversation
|
|
||
| // results looks like 172.17.0.0/16,172.17.0.1,1500 | ||
| vals := strings.Split(strings.TrimSpace(output), ",") | ||
| if len(vals) == 0 { |
There was a problem hiding this comment.
we can still check for length zero, right?
There was a problem hiding this comment.
I removed that because if the second argument of Split is non-empty, then it will always return a len of 1 or greater so the check will never be true.
There was a problem hiding this comment.
ah yeah i see what you're saying, we're checking for output empty above, could we check for strings.TrimSpace(output) == "" just as a precaution?
There was a problem hiding this comment.
Yup, will update
Done
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: medyagh, spowelljr The full list of commands accepted by this bot can be found here. The pull request process is described here DetailsNeeds approval from an approver in each of these files:
Approvers can indicate their approval by writing |
Fixes #12489
Problem:
We had an incorrect len check, we'd check if the slice had at least one element, but then we'd try accessing the second (index 1) element, which may not exist, resulting in out of bounds exception being thrown.
Solution:
Fix len check and add test for the function.