nim-lang/zip

Incorrect version check in deflateInit, inflateInit, etc.

snej opened this issue · 0 comments

snej commented

The inflate/deflateInit group of functions are implemented in C as macros that call the actual functions and tack on extra arguments including the string ZLIB_VERSION.

The Nim equivalents of these are functions that tack on zlibVersion(). That's not the same thing — it's the runtime version, whereas ZLIB_VERSION is the compile-time version. The purpose of this check is to find out what version the client was compiled with, and passing a runtime version defeats that.

Fix is to

  • Add a string constant ZLIB_VERSION whose value is the one from the version of zlib.h that the Nim interface was translated from;
  • Use this instead of zlibVersion() in the init functions.

I'll probably be submitting a PR soon.