You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by gu...@apache.org on 2021/10/11 19:39:57 UTC

[incubator-nuttx] 03/03: libc/vsprintf_internal: Call va_copy just like vsyslog

This is an automated email from the ASF dual-hosted git repository.

gustavonihei pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-nuttx.git

commit 1e607a70bcfe94959ecc62bc0e41f7b21201dd08
Author: Xiang Xiao <xi...@xiaomi.com>
AuthorDate: Sat Oct 9 14:32:59 2021 +0800

    libc/vsprintf_internal: Call va_copy just like vsyslog
    
    Signed-off-by: Xiang Xiao <xi...@xiaomi.com>
---
 libs/libc/stdio/lib_libvsprintf.c | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/libs/libc/stdio/lib_libvsprintf.c b/libs/libc/stdio/lib_libvsprintf.c
index 5dc7121..6e0fef0 100644
--- a/libs/libc/stdio/lib_libvsprintf.c
+++ b/libs/libc/stdio/lib_libvsprintf.c
@@ -464,7 +464,15 @@ static int vsprintf_internal(FAR struct lib_outstream_s *stream,
           if (fmt_char(fmt) == 'V')
             {
               FAR struct va_format *vaf = va_arg(ap, void *);
+#ifdef va_copy
+              va_list copy;
+
+              va_copy(copy, *vaf->va);
+              vsprintf_internal(stream, NULL, 0, vaf->fmt, copy);
+              va_end(copy);
+#else
               vsprintf_internal(stream, NULL, 0, vaf->fmt, *vaf->va);
+#endif
               continue;
             }
           else