Save the va_list so it can be reused if needed.
The second call to vsnprintf() needs to have a copy of the argument list so it can run correctly. On some system vsnprintf() destorys the original argument list.
This commit is contained in:
parent
9d5f438872
commit
5794098aa4
|
|
@ -180,6 +180,8 @@ vpi_mcd_vprintf(PLI_UINT32 mcd, const char*fmt, va_list ap)
|
||||||
char *buf_ptr = buffer;
|
char *buf_ptr = buffer;
|
||||||
int rc = 0;
|
int rc = 0;
|
||||||
bool need_free = false;
|
bool need_free = false;
|
||||||
|
va_list save_ap;
|
||||||
|
va_copy(save_ap, ap);
|
||||||
|
|
||||||
if (!IS_MCD(mcd)) return 0;
|
if (!IS_MCD(mcd)) return 0;
|
||||||
|
|
||||||
|
|
@ -206,9 +208,9 @@ vpi_mcd_vprintf(PLI_UINT32 mcd, const char*fmt, va_list ap)
|
||||||
buf_ptr = (char *)malloc(rc + 1);
|
buf_ptr = (char *)malloc(rc + 1);
|
||||||
need_free = true;
|
need_free = true;
|
||||||
#ifdef __MINGW32__
|
#ifdef __MINGW32__
|
||||||
rc = _vsnprintf(buf_ptr, rc+1, fmt, ap);
|
rc = _vsnprintf(buf_ptr, rc+1, fmt, save_ap);
|
||||||
#else
|
#else
|
||||||
rc = vsnprintf(buf_ptr, rc+1, fmt, ap);
|
rc = vsnprintf(buf_ptr, rc+1, fmt, save_ap);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue