diff --git a/vvp/vpi_mcd.cc b/vvp/vpi_mcd.cc index 2406cd7a0..8a776864d 100644 --- a/vvp/vpi_mcd.cc +++ b/vvp/vpi_mcd.cc @@ -180,6 +180,8 @@ vpi_mcd_vprintf(PLI_UINT32 mcd, const char*fmt, va_list ap) char *buf_ptr = buffer; int rc = 0; bool need_free = false; + va_list save_ap; + va_copy(save_ap, ap); 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); need_free = true; #ifdef __MINGW32__ - rc = _vsnprintf(buf_ptr, rc+1, fmt, ap); + rc = _vsnprintf(buf_ptr, rc+1, fmt, save_ap); #else - rc = vsnprintf(buf_ptr, rc+1, fmt, ap); + rc = vsnprintf(buf_ptr, rc+1, fmt, save_ap); #endif }