libgit2/objective-git — pull request #62 by rowanj (2012-04-25 13:37:30+00:00)
Title: Handle a NULL dereference causing a segfault

Stumbling blindly through the code while hacking away offline; I sent a gibberish string to

- (GTIndexEntry *) [GTIndex entryWithName:(NSString *)name]

If the string isn't found by `git_index_find(...)`, `git_index_get(...)` returns a NULL, which is passed blindly to

+ (id) [GTIndexEntry indexEntryWithEntry:(git_index_entry *)theEntry]

The `- (id) init` method of which promptly dereferences the NULL pointer, resulting in a good ol' SIGSEGV.

Here is my hacky handling - it'd probably be good to also check for the error state at the time of `git_index_find(...)` - but I didn't have the docs available at the time and I haven't read the new error handling document yet so I'm not up to speed on what the expected error handling behaviour is.

Regards,
- Rowan James