Browse Source

apply: free unused fragments for submodule patch

We simply discarded the fragments that we are not going to use upon seeing
a patch to update the submodule commit bound at path that we have not
checked out.

Free these fragments, not to leak them.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
maint
Junio C Hamano 13 years ago
parent
commit
9d16c2d514
  1. 24
      builtin/apply.c

24
builtin/apply.c

@ -196,17 +196,20 @@ struct patch {
struct patch *next; struct patch *next;
}; };


static void free_patch(struct patch *patch) static void free_fragment_list(struct fragment *list)
{ {
struct fragment *fragment = patch->fragments; while (list) {

struct fragment *next = list->next;
while (fragment) { if (list->free_patch)
struct fragment *fragment_next = fragment->next; free((char *)list->patch);
if (fragment->patch != NULL && fragment->free_patch) free(list);
free((char *)fragment->patch); list = next;
free(fragment);
fragment = fragment_next;
} }
}

static void free_patch(struct patch *patch)
{
free_fragment_list(patch->fragments);
free(patch->def_name); free(patch->def_name);
free(patch->old_name); free(patch->old_name);
free(patch->new_name); free(patch->new_name);
@ -2992,7 +2995,10 @@ static int apply_data(struct patch *patch, struct stat *st, struct cache_entry *
/* /*
* There is no way to apply subproject * There is no way to apply subproject
* patch without looking at the index. * patch without looking at the index.
* NEEDSWORK: shouldn't this be flagged
* as an error???
*/ */
free_fragment_list(patch->fragments);
patch->fragments = NULL; patch->fragments = NULL;
} }
} else { } else {

Loading…
Cancel
Save