@@ -1763,7 +1763,6 @@ static int read_next_command(void)
17631763 } else {
17641764 struct recent_command * rc ;
17651765
1766- strbuf_detach (& command_buf , NULL );
17671766 stdin_eof = strbuf_getline_lf (& command_buf , stdin );
17681767 if (stdin_eof )
17691768 return EOF ;
@@ -1784,7 +1783,7 @@ static int read_next_command(void)
17841783 free (rc -> buf );
17851784 }
17861785
1787- rc -> buf = command_buf .buf ;
1786+ rc -> buf = xstrdup ( command_buf .buf ) ;
17881787 rc -> prev = cmd_tail ;
17891788 rc -> next = cmd_hist .prev ;
17901789 rc -> prev -> next = rc ;
@@ -1833,7 +1832,6 @@ static int parse_data(struct strbuf *sb, uintmax_t limit, uintmax_t *len_res)
18331832 char * term = xstrdup (data );
18341833 size_t term_len = command_buf .len - (data - command_buf .buf );
18351834
1836- strbuf_detach (& command_buf , NULL );
18371835 for (;;) {
18381836 if (strbuf_getline_lf (& command_buf , stdin ) == EOF )
18391837 die ("EOF in data (terminator '%s' not found)" , term );
@@ -2588,7 +2586,7 @@ static void parse_new_commit(const char *arg)
25882586 struct branch * b ;
25892587 char * author = NULL ;
25902588 char * committer = NULL ;
2591- const char * encoding = NULL ;
2589+ char * encoding = NULL ;
25922590 struct hash_list * merge_list = NULL ;
25932591 unsigned int merge_count ;
25942592 unsigned char prev_fanout , new_fanout ;
@@ -2611,8 +2609,10 @@ static void parse_new_commit(const char *arg)
26112609 }
26122610 if (!committer )
26132611 die ("Expected committer but didn't get one" );
2614- if (skip_prefix (command_buf .buf , "encoding " , & encoding ))
2612+ if (skip_prefix (command_buf .buf , "encoding " , & v )) {
2613+ encoding = xstrdup (v );
26152614 read_next_command ();
2615+ }
26162616 parse_data (& msg , 0 , NULL );
26172617 read_next_command ();
26182618 parse_from (b );
@@ -2686,6 +2686,7 @@ static void parse_new_commit(const char *arg)
26862686 strbuf_addbuf (& new_data , & msg );
26872687 free (author );
26882688 free (committer );
2689+ free (encoding );
26892690
26902691 if (!store_object (OBJ_COMMIT , & new_data , NULL , & b -> oid , next_mark ))
26912692 b -> pack_id = pack_id ;
0 commit comments