zeromq/czmq — pull request #306 by pijyoi (2013-11-16 03:23:45+00:00)
Title: add additional test for zsys_vprintf exposing bug in implementation

The refactoring of vsnprintf code from zstr.c to zsys.c has created a bug that is exposed by this test.
This test has been executed on the following platforms:
Windows 32-bits: passes
Linux 64-bits: segfaults

The reason: A va_list can only be used once between a va_start / va_end pair. In order to use a va_list more than once, a copy has to be made. On 32-bit platforms, a va_list could be simply a pointer and thus passing it as a function parameter gets it copied. On 64-bit platforms, the va_list may be a more complex structure that can only be copied using C99's va_copy.

There was duplicated code in zstr.c in order to make the code work on compilers not supporting C99.