Message ID | 20210725130830.5145-2-andrzej@ahunt.org (mailing list archive) |
---|---|
State | Accepted |
Commit | 9fa62137314437162bf3e022f44c1fa8e5b43b50 |
Headers | show |
Series | [v2,01/12] fmt-merge-msg: free newly allocated temporary strings when done | expand |
andrzej@ahunt.org writes: > diff --git a/fmt-merge-msg.c b/fmt-merge-msg.c > index 0f66818e0f..b969dc6ebb 100644 > --- a/fmt-merge-msg.c > +++ b/fmt-merge-msg.c > @@ -108,6 +108,7 @@ static int handle_line(char *line, struct merge_parents *merge_parents) > struct origin_data *origin_data; > char *src; > const char *origin, *tag_name; > + char *to_free = NULL; > struct src_data *src_data; > struct string_list_item *item; > int pulling_head = 0; > @@ -183,12 +184,13 @@ static int handle_line(char *line, struct merge_parents *merge_parents) > if (!strcmp(".", src) || !strcmp(src, origin)) { > int len = strlen(origin); > if (origin[0] == '\'' && origin[len - 1] == '\'') > - origin = xmemdupz(origin + 1, len - 2); > + origin = to_free = xmemdupz(origin + 1, len - 2); > } else > - origin = xstrfmt("%s of %s", origin, src); > + origin = to_free = xstrfmt("%s of %s", origin, src); > if (strcmp(".", src)) > origin_data->is_local_branch = 0; > string_list_append(&origins, origin)->util = origin_data; > + free(to_free); > return 0; > } Thanks; obviously correct.
diff --git a/fmt-merge-msg.c b/fmt-merge-msg.c index 0f66818e0f..b969dc6ebb 100644 --- a/fmt-merge-msg.c +++ b/fmt-merge-msg.c @@ -108,6 +108,7 @@ static int handle_line(char *line, struct merge_parents *merge_parents) struct origin_data *origin_data; char *src; const char *origin, *tag_name; + char *to_free = NULL; struct src_data *src_data; struct string_list_item *item; int pulling_head = 0; @@ -183,12 +184,13 @@ static int handle_line(char *line, struct merge_parents *merge_parents) if (!strcmp(".", src) || !strcmp(src, origin)) { int len = strlen(origin); if (origin[0] == '\'' && origin[len - 1] == '\'') - origin = xmemdupz(origin + 1, len - 2); + origin = to_free = xmemdupz(origin + 1, len - 2); } else - origin = xstrfmt("%s of %s", origin, src); + origin = to_free = xstrfmt("%s of %s", origin, src); if (strcmp(".", src)) origin_data->is_local_branch = 0; string_list_append(&origins, origin)->util = origin_data; + free(to_free); return 0; }