Andrew's git
/
gitweb.git
/ diff
summary
|
log
|
commit
| diff |
tree
commit
grep
author
committer
pickaxe
?
re
mailinfo: plug strbuf leak during continuation line handling
author
Junio C Hamano
<gitster@pobox.com>
Tue, 20 Oct 2015 21:32:32 +0000
(14:32 -0700)
committer
Junio C Hamano
<gitster@pobox.com>
Wed, 21 Oct 2015 22:18:50 +0000
(15:18 -0700)
Whether this loop is left via EOF/break or upon finding a
non-continuation line, the storage used for the contination line
handling is left behind.
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin/mailinfo.c
patch
|
blob
|
history
raw
|
patch
|
inline
| side by side (parent:
e38ee06
)
diff --git
a/builtin/mailinfo.c
b/builtin/mailinfo.c
index 73be47c4975c961f2a438ec683e7148ccf2e9a88..a183cd49fd3eb807d1308bd97f3b75dd7736f515 100644
(file)
--- a/
builtin/mailinfo.c
+++ b/
builtin/mailinfo.c
@@
-409,6
+409,8
@@
static int is_rfc2822_header(const struct strbuf *line)
static int read_one_header_line(struct strbuf *line, FILE *in)
{
static int read_one_header_line(struct strbuf *line, FILE *in)
{
+ struct strbuf continuation = STRBUF_INIT;
+
/* Get the first part of the line. */
if (strbuf_getline(line, in, '\n'))
return 0;
/* Get the first part of the line. */
if (strbuf_getline(line, in, '\n'))
return 0;
@@
-430,7
+432,6
@@
static int read_one_header_line(struct strbuf *line, FILE *in)
*/
for (;;) {
int peek;
*/
for (;;) {
int peek;
- struct strbuf continuation = STRBUF_INIT;
peek = fgetc(in); ungetc(peek, in);
if (peek != ' ' && peek != '\t')
peek = fgetc(in); ungetc(peek, in);
if (peek != ' ' && peek != '\t')
@@
-441,6
+442,7
@@
static int read_one_header_line(struct strbuf *line, FILE *in)
strbuf_rtrim(&continuation);
strbuf_addbuf(line, &continuation);
}
strbuf_rtrim(&continuation);
strbuf_addbuf(line, &continuation);
}
+ strbuf_release(&continuation);
return 1;
}
return 1;
}