diff options
author | Jarkko Hietaniemi <jhi@iki.fi> | 2014-04-23 12:53:42 -0400 |
---|---|---|
committer | Tony Cook <tony@develop-help.com> | 2014-05-29 16:20:18 +1000 |
commit | 3ed3a8afebd64616aef147205403b96b30a4b4ee (patch) | |
tree | 17ccf956ff4b2802650f5c391dda020e0014e1a6 /mathoms.c | |
parent | dc21de0ce42c790f35d2d6062e09e01e787138af (diff) | |
download | perl-3ed3a8afebd64616aef147205403b96b30a4b4ee.tar.gz |
add va_end() calls where missing for a va_start() or va_end().
Fix for Coverity perl5 CIDs 29225, 29226, 29227, 29228, 29229: Missing
varargs init or cleanup (VARARGS) missing va_end: va_end was not
called for foo.
Use of va_args must be finished off with va_end (in other words,
use of va_start or va_copy must be bracketed off with va_end).
In most platforms va_end is a no-op, but in some platforms it is
required for proper cleanup (or face stack smash, or memory leak).
Tony: move va_start() out of the declaration block
Diffstat (limited to 'mathoms.c')
-rw-r--r-- | mathoms.c | 10 |
1 files changed, 8 insertions, 2 deletions
@@ -544,6 +544,7 @@ int Perl_fprintf_nocontext(PerlIO *stream, const char *format, ...) { dTHXs; + int ret = 0; va_list(arglist); /* Easier to special case this here than in embed.pl. (Look at what it @@ -553,7 +554,9 @@ Perl_fprintf_nocontext(PerlIO *stream, const char *format, ...) #endif va_start(arglist, format); - return PerlIO_vprintf(stream, format, arglist); + ret = PerlIO_vprintf(stream, format, arglist); + va_end(arglist); + return ret; } int @@ -561,13 +564,16 @@ Perl_printf_nocontext(const char *format, ...) { dTHX; va_list(arglist); + int ret = 0; #ifdef PERL_IMPLICIT_CONTEXT PERL_ARGS_ASSERT_PRINTF_NOCONTEXT; #endif va_start(arglist, format); - return PerlIO_vprintf(PerlIO_stdout(), format, arglist); + ret = PerlIO_vprintf(PerlIO_stdout(), format, arglist); + va_end(arglist); + return ret; } #if defined(HUGE_VAL) || (defined(USE_LONG_DOUBLE) && defined(HUGE_VALL)) |