Skip to content

Commit

Permalink
Merge branch '2.17'
Browse files Browse the repository at this point in the history
  • Loading branch information
cowtowncoder committed Dec 12, 2023
2 parents a1973e1 + f87f51b commit 66f2941
Show file tree
Hide file tree
Showing 4 changed files with 52 additions and 4 deletions.
6 changes: 6 additions & 0 deletions release-notes/CREDITS-2.x
Original file line number Diff line number Diff line change
Expand Up @@ -244,3 +244,9 @@ Peter Haumer (phaumer@github)

* Reported #404: (yaml) Cannot serialize YAML with Deduction-Based Polymorphism
(2.15.1)

Arthur Chan (arthurscchan@github)

* Contributed fix for #445: `YAMLParser` throws unexpected `NullPointerException` in certain
number parsing cases
(2.16.1)
6 changes: 6 additions & 0 deletions release-notes/VERSION-2.x
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,12 @@ Active Maintainers:

-

2.16.1 (not yet released)

#445: `YAMLParser` throws unexpected `NullPointerException` in certain
number parsing cases
(fix contributed by Arthur C)

2.16.0 (15-Nov-2023)

#198: (csv) Support writing numbers as quoted Strings with
Expand Down
16 changes: 12 additions & 4 deletions yaml/src/main/java/tools/jackson/dataformat/yaml/YAMLParser.java
Original file line number Diff line number Diff line change
Expand Up @@ -920,10 +920,18 @@ public Object getNumberValueDeferred() throws JacksonException {
// due to refactoring. So let's try to cobble something together

if (_currToken == JsonToken.VALUE_NUMBER_INT) {
// For integrals, use eager decoding for all ints, longs (and
// some cheaper BigIntegers)
if (_cleanedTextValue.length() <= 18) {
return getNumberValue();
// We might already have suitable value?
if ((_numTypesValid & NR_INT) != 0) {
return _numberInt;
}
if ((_numTypesValid & NR_LONG) != 0) {
return _numberLong;
}
if ((_numTypesValid & NR_BIGINT) != 0) {
return _getBigInteger();
}
if (_cleanedTextValue == null) {
_reportError("Internal number decoding error: `_cleanedTextValue` null when nothing decoded for `JsonToken.VALUE_NUMBER_INT`");
}
return _cleanedTextValue;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
package tools.jackson.dataformat.yaml.deser;

import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonProperty;

import tools.jackson.core.JacksonException;
import tools.jackson.core.JsonToken;
import tools.jackson.core.exc.StreamReadException;

Expand Down Expand Up @@ -88,4 +92,28 @@ public void testNumberDecoding61823() throws Exception
verifyException(e, "Invalid number");
}
}

// [dataformats-text#445]: NPE
static class ModelContainer445
{
public String string;

@JsonCreator
public ModelContainer445(@JsonProperty(value = "string") String string) {
this.string = string;
}
}

// [dataformats-text#445]: NPE
// https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=64662
public void testNullPointerException445_64662() throws Exception
{
// Content itself odd, generated by Fuzz; but needs to trigger buffering to work
try {
YAML_MAPPER.readValue(" :: ! 0000000000000000000000000000", ModelContainer445.class);
fail("Should not pass");
} catch (JacksonException e) {
verifyException(e, "Unrecognized property");
}
}
}

0 comments on commit 66f2941

Please sign in to comment.