1
0
mirror of https://github.com/golang/go synced 2024-11-17 06:04:47 -07:00

debug/buildinfo: avoid nil defererence for invalid XCOFF

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: 081a35ebec
GitHub-Pull-Request: golang/go#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>
This commit is contained in:
Jorropo 2022-05-05 23:31:20 +00:00 committed by Gopher Robot
parent f87e28d1b9
commit 119da6358b

View File

@ -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
}