-
Notifications
You must be signed in to change notification settings - Fork 14
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: nil pointers identified by nilaway (part 1) #512
Conversation
@@ -27,7 +27,7 @@ func toBytes(chars string) ([]byte, error) { | |||
for i := 0; i < len(chars); i++ { | |||
index := strings.IndexByte(charset, chars[i]) | |||
if index < 0 { | |||
return nil, ErrNonCharsetChar(chars[i]) | |||
return []byte{}, ErrNonCharsetChar(chars[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.
This is upstream vendored code. We should probably add a comment here
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.
Why is this vendored instead of being imported?
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.
I think it was to avoid the flood of deps from importing https://github.com/btcsuite/btcd
@@ -33,8 +33,14 @@ type GlobalFlags struct { | |||
} | |||
|
|||
func NewGlobalFlags() *GlobalFlags { | |||
var name string | |||
if os.Args == nil { |
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.
Is it actually possible for os.Args
to be nil
? It can technically be nil
because it's a byte slice, but the docs are fairly definitive: Args hold the command-line arguments, starting with the program name.
This doesn't hurt anything, though.
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.
It looks like it is possible, but I don't think it can ever happen in practice.
Signed-off-by: Chris Gianelloni <wolf31o2@blinklabs.io>
dd08f8f
to
14ab969
Compare
@@ -27,7 +27,7 @@ func toBytes(chars string) ([]byte, error) { | |||
for i := 0; i < len(chars); i++ { | |||
index := strings.IndexByte(charset, chars[i]) | |||
if index < 0 { | |||
return nil, ErrNonCharsetChar(chars[i]) | |||
return []byte{}, ErrNonCharsetChar(chars[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.
I think it was to avoid the flood of deps from importing https://github.com/btcsuite/btcd
No description provided.