@@ -190,27 +190,27 @@ void clear_mailmap(struct string_list *map)
190190int map_user (struct string_list * map ,
191191 char * email , int maxlen_email , char * name , int maxlen_name )
192192{
193- char * p ;
193+ char * end_of_email ;
194194 struct string_list_item * item ;
195195 struct mailmap_entry * me ;
196196 char buf [1024 ], * mailbuf ;
197197 int i ;
198198
199199 /* figure out space requirement for email */
200- p = strchr (email , '>' );
201- if (!p ) {
200+ end_of_email = strchr (email , '>' );
201+ if (!end_of_email ) {
202202 /* email passed in might not be wrapped in <>, but end with a \0 */
203- p = memchr (email , '\0' , maxlen_email );
204- if (!p )
203+ end_of_email = memchr (email , '\0' , maxlen_email );
204+ if (!end_of_email )
205205 return 0 ;
206206 }
207- if (p - email + 1 < sizeof (buf ))
207+ if (end_of_email - email + 1 < sizeof (buf ))
208208 mailbuf = buf ;
209209 else
210- mailbuf = xmalloc (p - email + 1 );
210+ mailbuf = xmalloc (end_of_email - email + 1 );
211211
212212 /* downcase the email address */
213- for (i = 0 ; i < p - email ; i ++ )
213+ for (i = 0 ; i < end_of_email - email ; i ++ )
214214 mailbuf [i ] = tolower (email [i ]);
215215 mailbuf [i ] = 0 ;
216216
@@ -236,6 +236,8 @@ int map_user(struct string_list *map,
236236 }
237237 if (maxlen_email && mi -> email )
238238 strlcpy (email , mi -> email , maxlen_email );
239+ else
240+ * end_of_email = '\0' ;
239241 if (maxlen_name && mi -> name )
240242 strlcpy (name , mi -> name , maxlen_name );
241243 debug_mm ("map_user: to '%s' <%s>\n" , name , mi -> email ? mi -> email : "" );
0 commit comments