mirror of
https://github.com/github/codeql.git
synced 2026-01-04 18:20:18 +01:00
JavaScript: Fix potential null-pointer exception in YAML extractor.
`ScalarEvent.getStyle()` is documented as returning `null` for plain scalars, so we need to handle that specially (cf https://github.com/Semmle/ql/blob/master/javascript/ql/src/semmle/javascript/YAML.qll#L100 for the corresponding code in the library, which expects plain style to be encoded as zero).
This commit is contained in:
committed by
Esben Sparre Andreasen
parent
6885b5cf1f
commit
a417884173
@@ -166,8 +166,10 @@ public class YAMLExtractor implements IExtractor {
|
||||
NodeId.scalar,
|
||||
scalar.getValue(),
|
||||
scalar.getImplicit().canOmitTagInPlainScalar());
|
||||
Character style = scalar.getStyle();
|
||||
int styleCode = style == null ? 0 : (int) style;
|
||||
trapWriter.addTuple(
|
||||
YAMLTables.YAML_SCALARS, label, (int) scalar.getStyle(), scalar.getValue());
|
||||
YAMLTables.YAML_SCALARS, label, styleCode, scalar.getValue());
|
||||
} else if (start.is(Event.ID.SequenceStart)) {
|
||||
kind = NodeKind.SEQUENCE;
|
||||
SequenceStartEvent sequenceStart = (SequenceStartEvent) start;
|
||||
|
||||
Reference in New Issue
Block a user