Olga Telezhnaya <olyatelezhnaya@xxxxxxxxx> writes: > Release item->value. > Initialize item->value->s dynamically and then release its resources. > Release some local variables. Again, "why" is lacking. > @@ -1373,36 +1379,31 @@ static void fill_remote_ref_details(struct used_atom *atom, const char *refname, > } > } else if (atom->u.remote_ref.option == RR_TRACKSHORT) { > if (stat_tracking_info(branch, &num_ours, &num_theirs, > - NULL, AHEAD_BEHIND_FULL) < 0) > + NULL, AHEAD_BEHIND_FULL) < 0) { > + *s = xstrdup(""); > return; It is a bit sad that we need to sprinkle xstrdup() all over the place, but I do not offhand think of a better alternative to ensure that it is safe to blindly free the .s field. > - if (explicit) > - *s = xstrdup(remote); > - else > - *s = ""; > + *s = explicit ? xstrdup(remote) : xstrdup(""); Next time, please avoid mixing this kind of unrelated changes with the main theme (i.e. "the original had allocated and static pieces of memory pointed by the same variable, which made it impossible to blindly free it, so make sure everything is allocated"). It makes it harder to let reviewers' eyes coast over the patch. I say "Next time" because the change is already written this time, and I already spent time to see it was an OK change. By the way, *s = xstrdup(explicit ? remote : ""); is probably shorter. > @@ -1562,10 +1566,11 @@ static int populate_value(struct ref_array_item *ref, struct strbuf *err) > if (!refname) > continue; > } > + free((char *)v->s); // we will definitely re-init it on the next line No // comment, please. > static void free_array_item(struct ref_array_item *item) > { > free((char *)item->symref); > + if (item->value) { > + free((char *)item->value->s); > + free(item->value); > + } > free(item); > } OK.