I wonder if we would have caught a regression like the one if we used FREE_AND_NULL more sparingly. For example, if we prematurely called clear_pathspec(), the second iteration, because there is free-and-null of pathspec->items and resetting pathspec->nr to 0, would behave very normally as if there is no pathspec. If we just freed things, without NULLing them out or resetting .nr to 0, the second iteration would try to access garbage and hopefully we will catch a crash before such a code would have escaped the lab. In any case, based on what I heard here, it appears that mimicking "git log" does may probably be a better way to deal with this regression? As you said, all the other things diff_free() calls are unwanted while "diff-tree --stdin" is still working, just like "log"? Thanks.