Skip to content

Conversation

@dumprop
Copy link
Contributor

@dumprop dumprop commented Apr 15, 2025

In the following code, there's a potential null dereference when constructing the message for ThrowArgumentNullException:
if (stub is null) ThrowHelper.ThrowArgumentNullException(nameof(stub), $"No suitable repeated serializer resolved for {stub.ForType.NormalizeName()}");
Code: https://github.com/protobuf-net/protobuf-net/blob/3.2.52/src/protobuf-net/Internal/Serializers/RepeatedDecorator.cs#L13

When stub is null, the code tries to access stub.ForType to include in the message, which will cause a null dereference exception before the ThrowArgumentNullException would be executed.

There would be deference of null because stub is null
@mgravell
Copy link
Member

Yep, good catch, thanks.

@mgravell mgravell merged commit 74b8b6f into protobuf-net:main Apr 15, 2025
1 check failed
This was referenced Jul 27, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants