Skip to content

Commit 544a55d

Browse files
author
Max Schaefer
committed
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).
1 parent 99c32f0 commit 544a55d

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

javascript/extractor/src/com/semmle/js/extractor/YAMLExtractor.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,8 +166,10 @@ private void extractNode(Label parent, int idx) {
166166
NodeId.scalar,
167167
scalar.getValue(),
168168
scalar.getImplicit().canOmitTagInPlainScalar());
169+
Character style = scalar.getStyle();
170+
int styleCode = style == null ? 0 : (int) style;
169171
trapWriter.addTuple(
170-
YAMLTables.YAML_SCALARS, label, (int) scalar.getStyle(), scalar.getValue());
172+
YAMLTables.YAML_SCALARS, label, styleCode, scalar.getValue());
171173
} else if (start.is(Event.ID.SequenceStart)) {
172174
kind = NodeKind.SEQUENCE;
173175
SequenceStartEvent sequenceStart = (SequenceStartEvent) start;

0 commit comments

Comments
 (0)