Fix ZSTD_readSkippableFrame with NULL dst#4226
Conversation
Summary: ZSTD_readSkippableFrame supports a NULL dst in the business logic but asserts if the frame size is greater than dst capacity. If dst is NULL, then dst capacity should be irrelevant. Test Plan: Read a skippable frame with a NULL dst just to get the frame size.
|
If the goal is to read the size of the skippable frame content, Another relevant method would be In contrast, |
|
Aha, got it. Yeah I think I was mostly confused why the inconsistency in the assertion vs the defensive coding of the function itself. Thanks! |
|
There may be some doc worth updating to reduce confusion |
following discussion at #4226
|
It would be nice (although I suppose, not frequently requested) to have an api to retrieve a skippable frame's magic variant without being forced to read the entire frame also. This PR would allow that. |
That's a good point. The way I see it, The structure If we were using If it feels too hackish, an alternative would be to employ one of the 2 remaining reserved fields for this purpose, and give it an explicit name (like |
|
There is a PoC at #4228 |
Summary:
ZSTD_readSkippableFrame supports a NULL dst in the business logic but asserts if the frame size is greater than dst capacity. If dst is NULL, then dst capacity should be irrelevant.
Test Plan:
Read a skippable frame with a NULL dst just to get the frame size.