Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes for issue #445: Wraps unexpected NullPointerException #446

Merged
merged 5 commits into from
Dec 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -1027,10 +1027,18 @@ public Object getNumberValueDeferred() throws IOException {
// 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,7 @@
package com.fasterxml.jackson.dataformat.yaml.deser;

import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.core.JacksonException;
import com.fasterxml.jackson.core.JsonToken;
import com.fasterxml.jackson.databind.JsonNode;
Expand Down Expand Up @@ -85,4 +87,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 field");
}
}
}