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

Bugfix/ls25001002/packed decode out of range #710

Merged
merged 2 commits into from
Feb 26, 2025

Conversation

dom-apuliasoft
Copy link
Collaborator

Description

Fix a corner case causing an out range error while decoding a packed number from a DS.

Technical notes

This PR covers a priorly not covered case in decodeFromPacked logic.

The issue arised when we assigned a value in range (0 .. 0,1) to a packed in a DS. As a reference, in the specific case where the issue was first found the exact assigned value 0.010000.

After the encoding process the resulting value in the DS was encoded truncating out the prefixing zeroes and dot (for instance in the mentioned case we kept 10000 in an encoded form). This is expected and common logic for all kind of packed number serialization we support.

To reverse this process during decode we rely on the target type. However the previous logic only considered cases where the dot had to be placed in the middle or after the number, not before it. Cases where the dot has to be prefixed arise whenever we decode an encoded value in range (0 .. 0,1) as already mentioned.

This was fixed by adding a check to detect this behaviour and reverse the encoding truncation.

Related to:

  • LS25001002

Checklist:

  • If this feature involves RPGLE fixes or improvements, they are well-described in the summary.
  • There are tests for this feature.
  • RPGLE code used for tests is easily understandable and includes comments that clarify the purpose of this feature.
  • The code follows Kotlin conventions (run ./gradlew ktlintCheck).
  • The code passes all tests (run ./gradlew check).
  • Relevant documentation is included in the docs directory.

@lanarimarco lanarimarco merged commit cb811f8 into develop Feb 26, 2025
1 check passed
@lanarimarco lanarimarco deleted the bugfix/LS25001002/packed-decode-out-of-range branch February 26, 2025 13:16
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