--- sa.c 2004/06/26 11:16:02 1.84
+++ sa.c 2004/06/26 11:38:20 1.85
@@ -2273,6 +2273,7 @@
sa_rc_t sa_sendf(sa_t *sa, sa_addr_t *raddr, const char *cpFmt, ...)
{
va_list ap;
+ va_list apbak;
int nBuf;
char *cpBuf;
sa_rc_t rv;
@@ -2284,9 +2285,10 @@
/* format string into temporary buffer */
va_start(ap, cpFmt);
+ va_copy(apbak, ap);
if ((nBuf = sa_mvsnprintf(NULL, 0, cpFmt, ap)) == -1)
return SA_RC(SA_ERR_FMT);
- va_end(ap);
+ va_copy(ap, apbak);
if ((nBuf+1) > (int)sizeof(caBuf)) {
/* requires a larger buffer, so allocate dynamically */
if ((cpBuf = (char *)malloc((size_t)(nBuf+1))) == NULL)
@@ -2296,7 +2298,6 @@
/* fits into small buffer, so allocate statically */
cpBuf = caBuf;
}
- va_start(ap, cpFmt);
rv = SA_OK;
if (sa_mvsnprintf(cpBuf, (size_t)(nBuf+1), cpFmt, ap) == -1)
rv = SA_ERR_FMT;
|