Skip to content

Commit 9b340d1

Browse files
committed
btf: don't crash when rebasing empty decoder
Accessing raw[0] is only valid if the length is > 0. Signed-off-by: Lorenz Bauer <lmb@isovalent.com>
1 parent 51ab2a4 commit 9b340d1

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

btf/unmarshal.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ func rebaseDecoder(d *decoder, base *decoder) (*decoder, error) {
170170
return nil, fmt.Errorf("rebase split spec: not a split spec")
171171
}
172172

173-
if &d.base.raw[0] != &base.raw[0] || len(d.base.raw) != len(base.raw) {
173+
if len(d.base.raw) != len(base.raw) || (len(d.base.raw) > 0 && &d.base.raw[0] != &base.raw[0]) {
174174
return nil, fmt.Errorf("rebase split spec: raw BTF differs")
175175
}
176176

0 commit comments

Comments
 (0)