Menu

Reviewing a va_list was not closed with va_end warning

Coldfirex
2021-07-17
2021-07-18
  • Coldfirex

    Coldfirex - 2021-07-17

    Howdy,
    I noticed we are getting this on one of our files.

    error: va_list 'args' was opening but not closed by va_end().  
    return -1;
    

    Here is the snippet of code:
    output_data(const char *format, ...)

    {
    va_list args;
    int len;
    char *buf;
    
    va_start(args, format);
    if ((len = vasprintf(&buf, format, args)) == -1)
    return -1;
    output_datalen(buf, len);
    va_end(args);
    free(buf);
    return (len);
    }
    

    I am new to this so pardon my ignorance. I got rid of the error by moving va_end before return -1; However, since its still called is this a non-issue, or just a best practice, etc.?

     
  • Daniel Marjamäki

    I am not sure but it seems to be a false positive. I have created https://trac.cppcheck.net/ticket/10369

     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.