Skip to content

Commit 7acfcfb

Browse files
Katsutoshi Ikenoyazwoop
authored andcommitted
Fixes some var-args missing va_start/end
This was introduced in #1299 But, the good news is that this has not been part of a release.
1 parent a80f072 commit 7acfcfb

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

lib/ts/ink_sprintf.cc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ ink_bvsprintf(char *buffer, const char *format, va_list ap)
6969
const char *s;
7070
char *d, *p, *s_val, d_buffer[32];
7171
va_list ap_local;
72+
7273
va_copy(ap_local, ap);
7374

7475
s = format;

proxy/http/HttpBodyFactory.h

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -162,15 +162,21 @@ class HttpBodyFactory
162162
getFormat(int64_t max_buffer_length, int64_t *resulting_buffer_length, const char *format, ...)
163163
{
164164
char *msg = nullptr;
165-
va_list ap;
166165
if (format) {
166+
va_list ap;
167+
168+
va_start(ap, format);
169+
167170
// The length from ink_bvsprintf includes the trailing NUL, so adjust the final
168-
// length accordingly.
171+
// length accordingly. Note that ink_bvsprintf() copies the va_list, so we only
172+
// have to set it up once.
169173
int l = ink_bvsprintf(nullptr, format, ap);
174+
170175
if (l <= max_buffer_length) {
171176
msg = (char *)ats_malloc(l);
172177
*resulting_buffer_length = ink_bvsprintf(msg, format, ap) - 1;
173178
}
179+
va_end(ap);
174180
}
175181
return msg;
176182
}

0 commit comments

Comments
 (0)