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

sanitizer.Sanitize may cause panic #222

Closed
wzy9607 opened this issue Mar 16, 2024 · 2 comments
Closed

sanitizer.Sanitize may cause panic #222

wzy9607 opened this issue Mar 16, 2024 · 2 comments
Labels
released This feature/bug fix has been released

Comments

@wzy9607
Copy link

wzy9607 commented Mar 16, 2024

Describe the bug

sanitizer.Sanitize may cause panic by calling value method using nil pointer.

Steps to reproduce

  1. Run the Example code snippet
  2. See a panic

Environment

  • Bugsnag Go version: 2.3.0
  • Go version: 1.22.1
  • Integration framework version:
    • Martini:
    • Negroni:
    • net/http:
    • Revel:
    • Other:

Example code snippet

package main

import (
	"errors"

	bugsnago "github.com/bugsnag/bugsnag-go/v2"
)

type Name struct {
	name string
}

func (n Name) String() string {
	return n.name
}

type data struct {
	Name *Name
}

func main() {
	err := errors.New("error")
	meta := bugsnago.MetaData{}
	meta.AddStruct("data", map[string]any{
		"data": data{Name: nil},
	})
	_ = bugsnago.Notify(err, meta)
}
Error messages:
panic: value method main.Name.String called using nil *Name pointer

goroutine 1 [running]:
main.(*Name).String(0xc00006c0e0?)
        <autogenerated>:1 +0x25
github.com/bugsnag/bugsnag-go/v2.sanitizer.Sanitize({{0x0, 0x0, 0x0}, {0xc00002e240, 0x3, 0x4}}, {0xec50fc0, 0x0})
        /Users/user/go/pkg/mod/github.com/bugsnag/bugsnag-go/v2@v2.3.0/metadata.go:98 +0x7b
...
...
...
@wzy9607
Copy link
Author

wzy9607 commented Mar 17, 2024

I see there is already a pr #221 fixing this, so I'll close this issue.

@wzy9607 wzy9607 closed this as completed Mar 17, 2024
@DariaKunoichi
Copy link
Contributor

@wzy9607 Hey, the fix is merged and released in v2.3.1.

@mclack mclack added the released This feature/bug fix has been released label Mar 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
released This feature/bug fix has been released
Projects
None yet
Development

No branches or pull requests

3 participants