]> Cypherpunks repositories - gostls13.git/commitdiff
debug/buildinfo: avoid nil defererence for invalid XCOFF
authorJorropo <jorropo.pgm@gmail.com>
Thu, 5 May 2022 23:31:20 +0000 (23:31 +0000)
committerGopher Robot <gobot@golang.org>
Fri, 6 May 2022 14:33:48 +0000 (14:33 +0000)
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: 081a35ebec9b94c0fa6a1347806d84111e58210a
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>
src/debug/buildinfo/buildinfo.go

index 8de03ff1063ffb1feb34d09ffd8f774e9fce303d..d1f489275196132c828d1c73ea46e8df51cd05aa 100644 (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
 }