Skip to content

Commit 2cb0d9e

Browse files
authored
Merge pull request #2712 from pqarmitage/updates
lib: fix va_start()/va_end() calls in safe_snprintf()
2 parents fd02900 + 67725dc commit 2cb0d9e

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

lib/safe_snprintf.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,12 @@ safe_snprintf(char *buf, size_t buf_size, const char *format, ...)
3939
size_t required_buf_size;
4040
va_list args;
4141

42-
va_start(args, format);
4342

4443
do {
44+
va_start(args, format);
4545
required_buf_size = vsnprintf(obuf, buf_size, format, args);
46+
va_end(args);
47+
4648
if (required_buf_size < buf_size)
4749
break;
4850

@@ -53,7 +55,5 @@ safe_snprintf(char *buf, size_t buf_size, const char *format, ...)
5355
obuf = MALLOC(buf_size = required_buf_size + 1);
5456
} while (true);
5557

56-
va_end(args);
57-
5858
return obuf;
5959
}

0 commit comments

Comments
 (0)