Skip to content

Commit fbbcafd

Browse files
committed
mailinfo: do not let find_boundary() touch global "line" directly
With the previous two commits, we established that the local variable "line" in handle_body() and handle_boundary() functions always refer to the global "line" that is used as the common and shared "current line from the input". They are the only callers of the last function that refers to the global line directly, i.e. find_boundary(). Pass "line" as a parameter to this leaf function to complete the clean-up. Now the only function that directly refers to the global "line" is the caller of handle_body() at the very beginning of this whole callchain. Signed-off-by: Junio C Hamano <[email protected]>
1 parent 69e24de commit fbbcafd

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

builtin/mailinfo.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -786,10 +786,10 @@ static int read_one_header_line(struct strbuf *line, FILE *in)
786786
return 1;
787787
}
788788

789-
static int find_boundary(void)
789+
static int find_boundary(struct strbuf *line)
790790
{
791-
while (!strbuf_getline(&line, fin, '\n')) {
792-
if (*content_top && is_multipart_boundary(&line))
791+
while (!strbuf_getline(line, fin, '\n')) {
792+
if (*content_top && is_multipart_boundary(line))
793793
return 1;
794794
}
795795
return 0;
@@ -821,7 +821,7 @@ static int handle_boundary(struct strbuf *line, int *filter_stage, int *header_s
821821
strbuf_release(&newline);
822822

823823
/* skip to the next boundary */
824-
if (!find_boundary())
824+
if (!find_boundary(line))
825825
return 0;
826826
goto again;
827827
}
@@ -850,7 +850,7 @@ static void handle_body(struct strbuf *line)
850850

851851
/* Skip up to the first boundary */
852852
if (*content_top) {
853-
if (!find_boundary())
853+
if (!find_boundary(line))
854854
goto handle_body_out;
855855
}
856856

0 commit comments

Comments
 (0)