Added defensiveness running out of bits during parse#8
Conversation
Within MsbBitReader, all calls to consuming bits come with a precondition check, which causes a crash if it fails. We did have some validation within the project for making sure enough bits were left before some calls; however, it was only in select places. This change makes all calls to DataReader throwing, with a check on whether enough bits are left before allowing them to be read. This may be a dent on performance; however, it is probably worth the extra protection against application crashes. This change is added because we found crashes in the wild due to badly formatted SCTE35 messages. These should be corrected; however, the parser should also be more defensive.
|
From the test output I can see the following: Comparing against the build that introduced metrics into main branch, I see: So the performance seems no worse. |
Within
MsbBitReader, all calls to consuming bits come with a precondition check, which causes a crash if it fails. We did have some validation within the project for making sure enough bits were left before some calls; however, it was only in select places. This change makes all calls to DataReader throwing, with a check on whether enough bits are left before allowing them to be read. This may be a dent on performance; however, it is probably worth the extra protection against application crashes.This change is added because we found crashes in the wild due to badly formatted SCTE35 messages. These should be corrected; however, the parser should also be more defensive.