From: Jonathon Mah Date: Fri, 25 Jan 2013 07:32:44 GMT Subject: Re: segmentation fault (nullpointer) with git log --submodule -p Message-ID: In-Reply-To: <20130125055331.GC26524@elie.Belkin> Just to note, the proposals so far don't prevent a "smart-ass" function from freeing the buffer when it's called underneath the use/release scope, as in: with_commit_buffer(commit); { fn1_needing_buffer(commit); walk_rev_tree_or_something(); fn2_needing_buffer(commit); } done_with_commit_buffer(commit); walk_rev_tree_or_something() might need to read commits to do its thing, and it could still choose to free their buffers (as in rev-list.c finish_commit()). If those commits includes the one being "retained", the call to fn2 will still see NULL despite it being in a 'protected scope'. Are the objections to using a reference count? Jonathon Mah me@JonathonMah.com