shoco icon indicating copy to clipboard operation
shoco copied to clipboard

Input string in compress must be null terminated even when len provided

Open dgreatwood opened this issue 9 years ago • 2 comments

I had some code where the input string "in" was not null-terminated for: size_t shoco_compress(const char * in, size_t len, char * out, size_t bufsize);

Specifically in := Building.txt/237/245/0 len := 12

shoco_compress encoded the two junk characters /237/245 and returned encoded array of length 10.

By providing a copy of the "in" string with terminating null: in := Building.txt/0 len := 12 it works fine, returning an encoded string length 8.

Easy work around but I was going off the API description: "If [len is] a positive integer, parsing the input will stop after this length, or at a null-char, whatever comes first." - which doesn't seem to be the case.

Hope this makes sense; and thanks for providing this library.

dgreatwood avatar Dec 06 '15 04:12 dgreatwood

Could you check whether this works now?

charmander avatar Dec 08 '15 23:12 charmander

Looks fixed now - thanks!

dgreatwood avatar Dec 09 '15 21:12 dgreatwood