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 #138: Move null checking to end of the conditional branch #139

Merged
merged 2 commits into from
Dec 19, 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 @@ -64,18 +64,17 @@ protected T _deserializeContents(JsonParser p, DeserializationContext ctxt)
continue;
}
value = _resolveNullToValue(ctxt);
if (value == null) {
if (value == null) {
_tryToAddNull(p, ctxt, builder);
continue;
}
}
} else if (typeDeser == null) {
value = valueDes.deserialize(p, ctxt);
} else {
value = valueDes.deserializeWithType(p, ctxt, typeDeser);
}

if (value == null) {
_tryToAddNull(p, ctxt, builder);
continue;
}

builder.add(value);
}
// No class outside of the package will be able to subclass us,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package com.fasterxml.jackson.datatype.guava.fuzz;

import org.junit.Assert;

import com.fasterxml.jackson.core.type.TypeReference;

import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.exc.MismatchedInputException;
import com.fasterxml.jackson.datatype.guava.ModuleTestBase;

import com.google.common.collect.ImmutableList;

/**
* Unit tests for verifying the fixes for OSS-Fuzz issues
* work as expected
* (see [datatypes-collections#138]).
*/
public class Fuzz138_65117Test extends ModuleTestBase
{
private final ObjectMapper MAPPER = mapperWithModule();

public void testOSSFuzzIssue65117() throws Exception
{
final TypeReference<?> ref = new TypeReference<ImmutableList<Integer>>() {};
MismatchedInputException e = Assert.assertThrows(
MismatchedInputException.class,
() -> MAPPER.readValue("[\"\"s(", ref));
verifyException(e, "Guava `Collection` of type ");
verifyException(e, "does not accept `null` values");
}
}
6 changes: 4 additions & 2 deletions release-notes/CREDITS-2.x
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,9 @@ Muhammad Khalikov (@mukham12)
(2.17.0)

Arthur Chan (@arthurscchan)
* Contributed #124: Some deserializers throw unexpected `NullPointerException`
* Contributed #124: (guava) Some deserializers throw unexpected `NullPointerException`
when handling invalid input
(2.17.0)

* Contributed #138: (guava) `GuavaCollectionDeserializer` still throws NPE in
some circumstances
(2.17.0)
4 changes: 3 additions & 1 deletion release-notes/VERSION-2.x
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,11 @@ Active Maintainers:
(contributed by Muhammad K)
#124: (guava) Some deserializers throw unexpected `NullPointerException` when
handling invalid input
(contibuted by Arthur C)
(contributed by Arthur C)
#136 (guava) Fix for failing Guava `Optional` test
(contributed by Muhammad K)
#138 (guava) `GuavaCollectionDeserializer` still throws NPE in some circumstances
(contributed by Arthur C)

2.16.0 (15-Nov-2023)

Expand Down
Loading