Commit 915e44c
read-cache: fix memleak
`ce` is allocated in make_cache_entry and should be freed if it is not
used any more. refresh_cache_entry as a wrapper around refresh_cache_ent
will either return
- the `ce` given as the parameter, when it was up-to-date;
- a new updated cache entry which is allocated to new memory; or
- a NULL when refreshing failed.
In the latter two cases, the original cache-entry `ce` is not used
and needs to be freed. The rule can be expressed as "if the return
value from refresh is different from the original ce, ce is no
longer used."
Helped-by: Junio C Hamano <[email protected]>
Signed-off-by: Stefan Beller <[email protected]>
Signed-off-by: Junio C Hamano <[email protected]>1 parent 067178e commit 915e44c
1 file changed
+2
-5
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
748 | 748 | | |
749 | 749 | | |
750 | 750 | | |
751 | | - | |
| 751 | + | |
752 | 752 | | |
753 | | - | |
754 | | - | |
755 | | - | |
756 | | - | |
| 753 | + | |
757 | 754 | | |
758 | 755 | | |
759 | 756 | | |
| |||
0 commit comments