diff: fix memory leak when appending a "too complex" diff entry

Found by Coverity Scan.

(cherry picked from commit ee2d079d1bf85ddaa0e6e54c6a39437eae500f5a)