Skip to content

Commit

Permalink
fix another null pointer dereference in S3
Browse files Browse the repository at this point in the history
  • Loading branch information
svenwltr committed Nov 3, 2017
1 parent 45fce27 commit 9e390b5
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
2 changes: 1 addition & 1 deletion resources/s3-buckets.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ func (n *S3Nuke) DescribeBuckets() ([]string, error) {
return nil, err
}

if *bucketLocationResponse.LocationConstraint == *n.Service.Config.Region {
if EqualStringPtr(bucketLocationResponse.LocationConstraint, n.Service.Config.Region) {
buckets = append(buckets, *out.Name)
}

Expand Down
12 changes: 12 additions & 0 deletions resources/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,15 @@ import (
func GetCategory(r Resource) string {
return strings.Split(fmt.Sprintf("%T", r), ".")[1] // hackey
}

func EqualStringPtr(v1, v2 *string) bool {
if v1 == nil && v2 == nil {
return true
}

if v1 == nil || v2 == nil {
return false
}

return *v1 == *v2
}

0 comments on commit 9e390b5

Please sign in to comment.