Skip to content
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

Merged
merged 1 commit into from Mar 5, 2024
Merged

Conversation

wolf31o2
Copy link
Member

@wolf31o2 wolf31o2 commented Mar 5, 2024

No description provided.

@@ -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])
Copy link
Contributor

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

Copy link
Member Author

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?

Copy link
Contributor

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

cmd/common/cmdline.go Outdated Show resolved Hide resolved
cmd/gouroboros/main.go Outdated Show resolved Hide resolved
@@ -33,8 +33,14 @@ type GlobalFlags struct {
}

func NewGlobalFlags() *GlobalFlags {
var name string
if os.Args == nil {
Copy link
Contributor

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.

Copy link
Member Author

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>
@@ -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])
Copy link
Contributor

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

@wolf31o2 wolf31o2 merged commit 490b5ab into main Mar 5, 2024
6 checks passed
@wolf31o2 wolf31o2 deleted the fix/nilaway-fixes branch March 5, 2024 16:12
@wolf31o2 wolf31o2 changed the title fix: fix nil pointers identified by nilaway (part 1) fix:nil pointers identified by nilaway (part 1) Mar 5, 2024
@wolf31o2 wolf31o2 changed the title fix:nil pointers identified by nilaway (part 1) fix: nil pointers identified by nilaway (part 1) Mar 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants