summaryrefslogtreecommitdiff
path: root/src/common
diff options
context:
space:
mode:
Diffstat (limited to 'src/common')
-rw-r--r--src/common/showmsg.c14
-rw-r--r--src/common/strlib.c3
2 files changed, 13 insertions, 4 deletions
diff --git a/src/common/showmsg.c b/src/common/showmsg.c
index c50716bed..fc1badd26 100644
--- a/src/common/showmsg.c
+++ b/src/common/showmsg.c
@@ -673,6 +673,7 @@ char timestamp_format[20] = ""; //For displaying Timestamps
int _vShowMessage(enum msg_type flag, const char *string, va_list ap)
{
+ va_list apcopy;
char prefix[100];
#if defined(DEBUGLOGMAP) || defined(DEBUGLOGCHAR) || defined(DEBUGLOGLOGIN)
FILE *fp;
@@ -734,12 +735,16 @@ int _vShowMessage(enum msg_type flag, const char *string, va_list ap)
if (flag == MSG_ERROR || flag == MSG_FATALERROR || flag == MSG_SQL)
{ //Send Errors to StdErr [Skotlex]
FPRINTF(STDERR, "%s ", prefix);
- VFPRINTF(STDERR, string, ap);
+ va_copy(apcopy, ap);
+ VFPRINTF(STDERR, string, apcopy);
+ va_end(apcopy);
FFLUSH(STDERR);
} else {
if (flag != MSG_NONE)
FPRINTF(STDOUT, "%s ", prefix);
- VFPRINTF(STDOUT, string, ap);
+ va_copy(apcopy, ap);
+ VFPRINTF(STDOUT, string, apcopy);
+ va_end(apcopy);
FFLUSH(STDOUT);
}
@@ -751,7 +756,9 @@ int _vShowMessage(enum msg_type flag, const char *string, va_list ap)
FFLUSH(STDERR);
} else {
fprintf(fp,"%s ", prefix);
- vfprintf(fp,string,ap);
+ va_copy(apcopy, ap);
+ vfprintf(fp,string,apcopy);
+ va_end(apcopy);
fclose(fp);
}
} else {
@@ -760,7 +767,6 @@ int _vShowMessage(enum msg_type flag, const char *string, va_list ap)
}
#endif
- va_end(ap);
return 0;
}
diff --git a/src/common/strlib.c b/src/common/strlib.c
index 93b69ab54..5580124e1 100644
--- a/src/common/strlib.c
+++ b/src/common/strlib.c
@@ -964,9 +964,12 @@ int StringBuf_Vprintf(StringBuf* self, const char* fmt, va_list ap)
for(;;)
{
+ va_list apcopy;
/* Try to print in the allocated space. */
size = self->max_ - (self->ptr_ - self->buf_);
+ va_copy(apcopy, ap);
n = vsnprintf(self->ptr_, size, fmt, ap);
+ va_end(ap);
/* If that worked, return the length. */
if( n > -1 && n < size )
{