-
Notifications
You must be signed in to change notification settings - Fork 18k
runtime: range over string with ill-formated string leads to nil pointer dereferenced #73597
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
Comments
First of all, code now should avoid using the
Lines 253 to 264 in 8ec5559
So i would say that this is the expected behavior, and such strings where data == nil and Len > 0 are invalid. |
I kind of figured that this would be the case. |
Go version
1.24
Output of
go env
in your module/workspace:What did you do?
I am working on a pretty big project where multiple libraries are working together. I have recently found out the weird following behaviour after one of the libraries in use produced a string with a nil-data pointer and a non-zero length.
https://go.dev/play/p/xGBLKtttmdC
I have put the example into this string, however here once again:
What did you see happen?
The range will panic since (presumably) the range does only check if the len is greater than 0, not if the Data pointer is valid.
What did you expect to see?
I am not sure if this is expected behaviour in the go runtime. I can also not tell you which of the libraries I use in my project produced such a string, however I will continue to investigate and try to find the broken library.
The text was updated successfully, but these errors were encountered: