mirror of
https://github.com/servalproject/serval-dna.git
synced 2024-12-20 05:37:57 +00:00
Fix use of va_copy() in logging functions
This commit is contained in:
parent
b8b31ed97a
commit
98fa034c53
10
log.c
10
log.c
@ -264,10 +264,7 @@ static void iterator_vprintf_nl(struct log_output_iterator *it, int level, struc
|
|||||||
assert(current_iterator);
|
assert(current_iterator);
|
||||||
log_start_line(it, level);
|
log_start_line(it, level);
|
||||||
whence_prefix(it, whence);
|
whence_prefix(it, whence);
|
||||||
va_list ap1;
|
vxprintf(it->xpf, fmt, ap);
|
||||||
va_copy(ap1, ap);
|
|
||||||
vxprintf(it->xpf, fmt, ap1);
|
|
||||||
va_end(ap1);
|
|
||||||
log_end_line(it, level);
|
log_end_line(it, level);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -300,7 +297,10 @@ void serval_vlogf(int level, struct __sourceloc whence, const char *fmt, va_list
|
|||||||
if (is_log_available(&it)) {
|
if (is_log_available(&it)) {
|
||||||
current_iterator = ⁢
|
current_iterator = ⁢
|
||||||
print_newdate(&it);
|
print_newdate(&it);
|
||||||
iterator_vprintf_nl(&it, level, whence, fmt, ap);
|
va_list ap1;
|
||||||
|
va_copy(ap1, ap);
|
||||||
|
iterator_vprintf_nl(&it, level, whence, fmt, ap1);
|
||||||
|
va_end(ap1);
|
||||||
log_flush(&it);
|
log_flush(&it);
|
||||||
current_iterator = NULL;
|
current_iterator = NULL;
|
||||||
}
|
}
|
||||||
|
10
xprintf.c
10
xprintf.c
@ -105,14 +105,20 @@ void _cx_vprintf_mallocbuf(void *context, const char *fmt, va_list ap)
|
|||||||
if (mb->current) {
|
if (mb->current) {
|
||||||
if (mb->current + 1 >= mb->buffer + mb->size)
|
if (mb->current + 1 >= mb->buffer + mb->size)
|
||||||
grow_mallocbuf(mb, 1024);
|
grow_mallocbuf(mb, 1024);
|
||||||
int n = vsnprintf(mb->current, mb->buffer + mb->size - mb->current, fmt, ap);
|
va_list ap1;
|
||||||
|
va_copy(ap1, ap);
|
||||||
|
int n = vsnprintf(mb->current, mb->buffer + mb->size - mb->current, fmt, ap1);
|
||||||
|
va_end(ap1);
|
||||||
char *newcurrent = mb->current + n;
|
char *newcurrent = mb->current + n;
|
||||||
char *end = mb->buffer + mb->size;
|
char *end = mb->buffer + mb->size;
|
||||||
if (newcurrent < end)
|
if (newcurrent < end)
|
||||||
mb->current = newcurrent;
|
mb->current = newcurrent;
|
||||||
else {
|
else {
|
||||||
grow_mallocbuf(mb, newcurrent - end + 1);
|
grow_mallocbuf(mb, newcurrent - end + 1);
|
||||||
n = vsnprintf(mb->current, mb->buffer + mb->size - mb->current, fmt, ap);
|
va_list ap1;
|
||||||
|
va_copy(ap1, ap);
|
||||||
|
n = vsnprintf(mb->current, mb->buffer + mb->size - mb->current, fmt, ap1);
|
||||||
|
va_end(ap1);
|
||||||
char *newcurrent = mb->current + n;
|
char *newcurrent = mb->current + n;
|
||||||
char *end = mb->buffer + mb->size;
|
char *end = mb->buffer + mb->size;
|
||||||
if (newcurrent < end)
|
if (newcurrent < end)
|
||||||
|
Loading…
Reference in New Issue
Block a user