libgit2/libgit2 — pull request #2051 by vmg (2014-01-15 14:10:07+00:00)
Title: PANIC! AT THE DISCO

After running some static analysis on the codebase, I noticed that we do a pretty poor job of handling codepaths where we run out of memory. Since it's 2014, we assume that that will never happen and hence we don't really do proper cleanup on OOM situations; however, we still have to manually check all allocations and unwind the stack if one of them fails, which makes for very verbose allocation checking.

This PR goes all the way and switches to the same behavior as `git.git`: when any allocation in the library fails, we panic and shutdown the library.

In our case, panic is implemented as `giterr_panic`, which by default prints and error message to `stderr` and exits the current process. However, for our user's convenience, a custom panic handler can be configured that will be called by the library (in case the user wants to crash with a particular error message, or maybe even trampoline out of the callstack, cleanup memory and try again).

Coincidentally (not really haha) this also removes a couple hundred warnings from our Coverity scans. Hihi.