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

FSE_compressU16() computes clipped data if dstCapacity different #97

Open
JohanKnutzen opened this issue Jan 3, 2019 · 1 comment
Open

Comments

@JohanKnutzen
Copy link

Repro:

constexpr size_t inSize = 24;
uint16_t in[inSize] =
  {0, 0, 3, 2, 0, 0, 0, 0, 314, 0, 0, 0, 0, 51, 50, 0, 0, 59, 22, 36, 0, 55, 32, 22};
unsigned int maxSymbolValue = 314;
unsigned int outSize = 48;

uint8_t out1[256];
uint8_t out2[256];
size_t        numBytes1 = FSE_compressU16(out1,
                                   outSize,
                                   in,
                                   inSize,
                                   maxSymbolValue,
                                   0);

size_t numBytes2 = FSE_compressU16(out2,
                                   256,
                                   in,
                                   inSize,
                                   maxSymbolValue,
                                   0);
// numBytes1 is now 34 bytes
// numBytes2 is now 43 bytes

FSE_decompressU16(in, inSize, out2, numBytes2);
FSE_decompressU16(in, inSize, out1, numBytes1); // <- Crashes 

When output bytes is 48 rather than 256 as an argument for FSE_compressU16(), all generated bytes are identical up until 34 bytes. The rest of the bytes are clipped. The difference in code paths is that in the 34 bytes case, the non-fast path is chosen.

@JohanKnutzen
Copy link
Author

Is this fixed in dev? I can test it if it is believed to be fixed.

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

No branches or pull requests

1 participant