Skip to content

Commit

Permalink
Fixes for #138: Move null checking to end of the conditional branch (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
arthurscchan authored Dec 19, 2023
1 parent 3b95db3 commit 8854403
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 9 deletions.
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

0 comments on commit 8854403

Please sign in to comment.