Skip to content

fix impossibility of a compound choice inside a set/sequence #34

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

GrigoriySokolov
Copy link

  • The bug was inspired by N1 codec migration to the new version of MED. As it was discovered, a med::choice with a compound header could not be placed into a med::set or med::sequence as a mandatory member.

  • It happened because of a process of postponed compound header tag filling. A tag was filled out during a med::choice encode process, just before encoding. That is, by the moment an outer container encoding, the choice header tag remained untouched. Hereby, pre-encode check of all mandatory fields filled caused an error reporting the emptyness of the mandatory field.

  • The fix moves the compound header tag filling from the encode stage to the earlier stage, namely while choice::ref() API is called.

  • this change a protocol of working with a choice. Now a user can call med::choice::ref() only once. To reuse a choice / refill some choice member, med::choice::clear() must be called prior to it..

  • The change also requires to distinguish a context within the ref() call happens. The decode stage, when the choice::ref() API is called by the engine, is the case. During the choice::ref call the header tag was already filled by the recent binary data reading and must not be touched.

  • To achieve it the new member method bool is_tag_set() was introduced. The new method must be presented in every class/struct where the get_tag() method is defined.

- The bug was inspired by N1 codec migration to the new version of MED.
As it was discovered, a med::choice with a compound header could not be
placed into a med::set or med::sequence as a mandatory member.

- It happened because of a process of postponed compound header tag filling.
A tag was filled out during a med::choice encode process, just before
encoding. That is, by the moment an outer container encoding, the choice
header tag remained untouched. Hereby, pre-encode check of all mandatory
fields filled caused an error reporting the emptyness of the mandatory
field.

- The fix moves the compound header tag filling from the encode stage to
  the earlier stage, namely while choice::ref() API is called.

- this change a protocol of working with a choice. Now a user can call
med::choice::ref() only once. To reuse a choice / refill some choice
member, med::choice::clear() must be called prior to it..

- The change also requires to distinguish a context within the ref()
  call happens. The decode stage, when the choice::ref() API is called
by the engine, is the case. During the choice::ref call the header tag
was already filled by the recent binary data reading and must not be
touched.

- To achieve it the new member method bool is_tag_set() was introduced.
  The new method must be presented in every class/struct where the
get_tag() method is defined.
@GrigoriySokolov GrigoriySokolov force-pushed the M_compound_choice_in_container branch from fe1ddc5 to 0853aa8 Compare April 11, 2025 18:47
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.

1 participant