Skip to content

Commit

Permalink
debug/buildinfo: avoid nil defererence for invalid XCOFF
Browse files Browse the repository at this point in the history
I've made it return 0 following what the other DataStart implementation
do when they do not found the section.

Fixes #52718

Change-Id: I44292fed15bb21b9aba712ad15ed74e0ce231b5a
GitHub-Last-Rev: 081a35e
GitHub-Pull-Request: #52722
Reviewed-on: https://go-review.googlesource.com/c/go/+/404254
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Ian Lance Taylor <iant@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: David Chase <drchase@google.com>
  • Loading branch information
Jorropo authored and gopherbot committed May 6, 2022
1 parent f87e28d commit 119da63
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/debug/buildinfo/buildinfo.go
Original file line number Diff line number Diff line change
Expand Up @@ -393,5 +393,8 @@ func (x *xcoffExe) ReadData(addr, size uint64) ([]byte, error) {
}

func (x *xcoffExe) DataStart() uint64 {
return x.f.SectionByType(xcoff.STYP_DATA).VirtualAddress
if s := x.f.SectionByType(xcoff.STYP_DATA); s != nil {
return s.VirtualAddress
}
return 0
}

0 comments on commit 119da63

Please sign in to comment.