[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-changelog] [xen master] tools/xenstore: Correct use of va_end() after va_copy()



commit de8c3e826499dbf69d01ee935a67b5d67a131496
Author:     Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
AuthorDate: Fri Aug 7 14:51:59 2015 +0100
Commit:     Ian Campbell <ian.campbell@xxxxxxxxxx>
CommitDate: Thu Aug 13 10:58:43 2015 +0100

    tools/xenstore: Correct use of va_end() after va_copy()
    
    C requires that every use of va_copy() is matched with a va_end() call.
    
    This is especially important for x86_64 as va_{start,copy}() may need to
    allocate memory to generate a va_list containing parameters which were
    previously in registers.
    
    Signed-off-by: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
    Acked-by: Wei Liu <wei.liu2@xxxxxxxxxx>
---
 tools/xenstore/talloc.c |    6 ++++++
 1 files changed, 6 insertions(+), 0 deletions(-)

diff --git a/tools/xenstore/talloc.c b/tools/xenstore/talloc.c
index 54dbd02..d7edcf3 100644
--- a/tools/xenstore/talloc.c
+++ b/tools/xenstore/talloc.c
@@ -1101,13 +1101,16 @@ char *talloc_vasprintf(const void *t, const char *fmt, 
va_list ap)
 
        /* this call looks strange, but it makes it work on older solaris boxes 
*/
        if ((len = vsnprintf(&c, 1, fmt, ap2)) < 0) {
+               va_end(ap2);
                return NULL;
        }
+       va_end(ap2);
 
        ret = _talloc(t, len+1);
        if (ret) {
                VA_COPY(ap2, ap);
                vsnprintf(ret, len+1, fmt, ap2);
+               va_end(ap2);
                talloc_set_name_const(ret, ret);
        }
 
@@ -1161,8 +1164,10 @@ static char *talloc_vasprintf_append(char *s, const char 
*fmt, va_list ap)
                 * the original string. Most current callers of this 
                 * function expect it to never return NULL.
                 */
+               va_end(ap2);
                return s;
        }
+       va_end(ap2);
 
        s = talloc_realloc(NULL, s, char, s_len + len+1);
        if (!s) return NULL;
@@ -1170,6 +1175,7 @@ static char *talloc_vasprintf_append(char *s, const char 
*fmt, va_list ap)
        VA_COPY(ap2, ap);
 
        vsnprintf(s+s_len, len+1, fmt, ap2);
+       va_end(ap2);
        talloc_set_name_const(s, s);
 
        return s;
--
generated by git-patchbot for /home/xen/git/xen.git#master

_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.