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:
Max Schaefer 2019-06-20 17:01:43 +01:00 коммит произвёл Esben Sparre Andreasen
Родитель 6885b5cf1f
Коммит a417884173
1 изменённых файлов: 3 добавлений и 1 удалений

Просмотреть файл

@ -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;