Fix validation bug from #546 causing failure for rest of day #548
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR fixes a bug introduced in #546 where a validation failure would cause every subsequent message to fail validation. #546 added validation for the length of boolean and char fields, asserting that the fix tag was only a single character long. Using
Rule80A(tag 47) as an example, a buffer would be created for the decoder:When a message was decoded, the value of the fix tag would be copied into the buffer:
getCharsis designed to create a new, larger buffer if the field it attempts to read is too large for the current buffer:The validation would then check the size of the buffer length:
Because the buffer was never resized/reset for each fix message, anytime large tag value was sent (e.g.
47=AB) the buffer size would be increased and remain that size. Each subsequent check of${tag}AsChars.lengthwould then fail.This PR removes the
${tag}AsCharsfield and replaces it with a${tag}Lengthfield for boolean and char fields that holds the length of the field to ensure subsequent messages with the correct length are valid. It maintains the same validation behavior while avoiding heap allocations for every message.