File tree Expand file tree Collapse file tree 1 file changed +8
-0
lines changed Expand file tree Collapse file tree 1 file changed +8
-0
lines changed Original file line number Diff line number Diff line change 5
5
6
6
package tree
7
7
8
+ import "github.com/cockroachdb/cockroach/pkg/util/buildutil"
9
+
8
10
// AnnotationIdx is the 1-based index of an annotation. AST nodes that can
9
11
// be annotated store such an index (unique within that AST).
10
12
type AnnotationIdx int32
@@ -22,6 +24,12 @@ func (n AnnotatedNode) GetAnnotation(ann *Annotations) interface{} {
22
24
if n .AnnIdx == NoAnnotation {
23
25
return nil
24
26
}
27
+ if (len (* ann ) < int (n .AnnIdx ) || int (n .AnnIdx ) < 1 ) && ! buildutil .CrdbTestBuild {
28
+ // Avoid index-out-of bounds panics in production builds. The impact is
29
+ // that the node will be treated as if it doesn't have the annotation,
30
+ // which is better than the process crash.
31
+ return nil
32
+ }
25
33
return ann .Get (n .AnnIdx )
26
34
}
27
35
You can’t perform that action at this time.
0 commit comments