Message ID | 20170730194037.21803-1-xypron.glpk@gmx.de |
---|---|
State | Accepted |
Commit | 36d35345b1f6124d7e1763c818ec29e1709f9eec |
Delegated to: | Tom Rini |
Headers | show |
On 30 July 2017 at 13:40, Heinrich Schuchardt <xypron.glpk@gmx.de> wrote: > va_start must always be matched by va_end. > > Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> > --- > lib/tpm.c | 5 ++++- > 1 file changed, 4 insertions(+), 1 deletion(-) > Reviewed-by: Simon Glass <sjg@chromium.org> But don't you think it would be better to 'goto' the end of the function and have va_end() once? Regards, Simon
On Sun, Jul 30, 2017 at 09:40:37PM +0200, xypron.glpk@gmx.de wrote: > va_start must always be matched by va_end. > > Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> > Reviewed-by: Simon Glass <sjg@chromium.org> Applied to u-boot/master, thanks!
diff --git a/lib/tpm.c b/lib/tpm.c index fb520e3d73..d1cf5a8a16 100644 --- a/lib/tpm.c +++ b/lib/tpm.c @@ -95,8 +95,10 @@ int pack_byte_string(uint8_t *str, size_t size, const char *format, ...) return -1; } - if (offset + length > size) + if (offset + length > size) { + va_end(args); return -1; + } switch (*format) { case 'b': @@ -163,6 +165,7 @@ int unpack_byte_string(const uint8_t *str, size_t size, const char *format, ...) length = va_arg(args, uint32_t); break; default: + va_end(args); debug("Couldn't recognize format string\n"); return -1; }
va_start must always be matched by va_end. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> --- lib/tpm.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)