ustream: prevent recursive calls to the read callback
[project/libubox.git] / udebug.c
index 31b0210d7068d36333485330a443359074277ba6..e39a32cb165f687325c7465d78b64c02a55e2713 100644 (file)
--- a/udebug.c
+++ b/udebug.c
@@ -610,6 +610,7 @@ int udebug_entry_vprintf(struct udebug_buf *buf, const char *fmt, va_list ap)
        struct udebug_ptr *ptr;
        uint32_t ofs;
        uint32_t len;
+       va_list ap2;
        char *str;
 
        if (!hdr)
@@ -621,7 +622,9 @@ int udebug_entry_vprintf(struct udebug_buf *buf, const char *fmt, va_list ap)
                return -1;
 
        str = udebug_buf_alloc(buf, ofs, UDEBUG_MIN_ALLOC_LEN);
-       len = vsnprintf(str, UDEBUG_MIN_ALLOC_LEN, fmt, ap);
+       va_copy(ap2, ap);
+       len = vsnprintf(str, UDEBUG_MIN_ALLOC_LEN, fmt, ap2);
+       va_end(ap2);
        if (len <= UDEBUG_MIN_ALLOC_LEN)
                goto out;