@@ -30,10 +30,10 @@ struct mailinfo {
30
30
int patch_lines ;
31
31
int filter_stage ; /* still reading log or are we copying patch? */
32
32
int header_stage ; /* still checking in-body headers? */
33
+ struct strbuf * * p_hdr_data ;
34
+ struct strbuf * * s_hdr_data ;
33
35
};
34
36
35
- static struct strbuf * * p_hdr_data , * * s_hdr_data ;
36
-
37
37
#define MAX_BOUNDARIES 5
38
38
39
39
static void cleanup_space (struct strbuf * sb )
@@ -663,7 +663,7 @@ static int handle_commit_msg(struct mailinfo *mi, struct strbuf *line)
663
663
}
664
664
665
665
if (mi -> use_inbody_headers && mi -> header_stage ) {
666
- mi -> header_stage = check_header (mi , line , s_hdr_data , 0 );
666
+ mi -> header_stage = check_header (mi , line , mi -> s_hdr_data , 0 );
667
667
if (mi -> header_stage )
668
668
return 0 ;
669
669
} else
@@ -688,9 +688,9 @@ static int handle_commit_msg(struct mailinfo *mi, struct strbuf *line)
688
688
* them to give ourselves a clean restart.
689
689
*/
690
690
for (i = 0 ; header [i ]; i ++ ) {
691
- if (s_hdr_data [i ])
692
- strbuf_release (s_hdr_data [i ]);
693
- s_hdr_data [i ] = NULL ;
691
+ if (mi -> s_hdr_data [i ])
692
+ strbuf_release (mi -> s_hdr_data [i ]);
693
+ mi -> s_hdr_data [i ] = NULL ;
694
694
}
695
695
return 0 ;
696
696
}
@@ -840,7 +840,7 @@ static int handle_boundary(struct mailinfo *mi, struct strbuf *line)
840
840
841
841
/* slurp in this section's info */
842
842
while (read_one_header_line (line , mi -> input ))
843
- check_header (mi , line , p_hdr_data , 0 );
843
+ check_header (mi , line , mi -> p_hdr_data , 0 );
844
844
845
845
strbuf_release (& newline );
846
846
/* replenish line */
@@ -941,10 +941,10 @@ static void handle_info(struct mailinfo *mi)
941
941
942
942
for (i = 0 ; header [i ]; i ++ ) {
943
943
/* only print inbody headers if we output a patch file */
944
- if (mi -> patch_lines && s_hdr_data [i ])
945
- hdr = s_hdr_data [i ];
946
- else if (p_hdr_data [i ])
947
- hdr = p_hdr_data [i ];
944
+ if (mi -> patch_lines && mi -> s_hdr_data [i ])
945
+ hdr = mi -> s_hdr_data [i ];
946
+ else if (mi -> p_hdr_data [i ])
947
+ hdr = mi -> p_hdr_data [i ];
948
948
else
949
949
continue ;
950
950
@@ -984,8 +984,8 @@ static int mailinfo(struct mailinfo *mi, const char *msg, const char *patch)
984
984
return -1 ;
985
985
}
986
986
987
- p_hdr_data = xcalloc (MAX_HDR_PARSED , sizeof (* p_hdr_data ));
988
- s_hdr_data = xcalloc (MAX_HDR_PARSED , sizeof (* s_hdr_data ));
987
+ mi -> p_hdr_data = xcalloc (MAX_HDR_PARSED , sizeof (* ( mi -> p_hdr_data ) ));
988
+ mi -> s_hdr_data = xcalloc (MAX_HDR_PARSED , sizeof (* ( mi -> s_hdr_data ) ));
989
989
990
990
do {
991
991
peek = fgetc (mi -> input );
@@ -994,7 +994,7 @@ static int mailinfo(struct mailinfo *mi, const char *msg, const char *patch)
994
994
995
995
/* process the email header */
996
996
while (read_one_header_line (& line , mi -> input ))
997
- check_header (mi , & line , p_hdr_data , 1 );
997
+ check_header (mi , & line , mi -> p_hdr_data , 1 );
998
998
999
999
handle_body (mi , & line );
1000
1000
fclose (mi -> patchfile );
@@ -1031,10 +1031,19 @@ static void setup_mailinfo(struct mailinfo *mi)
1031
1031
1032
1032
static void clear_mailinfo (struct mailinfo * mi )
1033
1033
{
1034
+ int i ;
1035
+
1034
1036
strbuf_release (& mi -> name );
1035
1037
strbuf_release (& mi -> email );
1036
1038
strbuf_release (& mi -> charset );
1037
1039
free (mi -> message_id );
1040
+
1041
+ for (i = 0 ; mi -> p_hdr_data [i ]; i ++ )
1042
+ strbuf_release (mi -> p_hdr_data [i ]);
1043
+ free (mi -> p_hdr_data );
1044
+ for (i = 0 ; mi -> s_hdr_data [i ]; i ++ )
1045
+ strbuf_release (mi -> s_hdr_data [i ]);
1046
+ free (mi -> s_hdr_data );
1038
1047
}
1039
1048
1040
1049
static const char mailinfo_usage [] =
0 commit comments