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

LzwDecode might omit characters #176

Open
stefan6419846 opened this issue Sep 27, 2024 · 0 comments
Open

LzwDecode might omit characters #176

stefan6419846 opened this issue Sep 27, 2024 · 0 comments

Comments

@stefan6419846
Copy link

When doing a code review of the LZW implementation inside this repository, I stumbled upon a possible issue for special cases in the LZW algorithm where dictionary lookups would be done before the corresponding entry has been added, corresponding to the

{
str = _stringTable[oldCode];
outputStream.Write(str, 0, str.Length);
AddEntry(str, str[0]);
oldCode = code;
}
branch.

In these cases (on line 66), the first character of the looked up string has to be appended to the output as well, as done when adding the dictionary entry itself. For reference, you might want to have a look at http://web.archive.org/web/20011214082531/http://www.rasip.fer.hr/research/compress/algorithms/fund/lz/lzw.html. (Unfortunately, I cannot provide any C# code here as I am no C# developer - I just stumbled upon this issue when reviewing some port of the corresponding functionality.)

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