Skip to content

Commit

Permalink
Merge pull request libgit2#62 from rowanj/ErrorHandling
Browse files Browse the repository at this point in the history
Handle a NULL dereference causing a segfault
  • Loading branch information
joshaber committed Apr 26, 2012
2 parents d19b3b1 + 3056fa2 commit d633d70
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions Classes/GTIndexEntry.m
Expand Up @@ -61,6 +61,9 @@ - (void)dealloc {
@synthesize repository;

+ (id)indexEntryWithEntry:(git_index_entry *)theEntry {
if (theEntry == NULL)
return nil;

return [[self alloc] initWithEntry:theEntry];
}

Expand All @@ -73,8 +76,11 @@ - (id)init {

- (id)initWithEntry:(git_index_entry *)theEntry {
if((self = [self init])) {
git_index_entry *thisEntry = self.git_index_entry;
memcpy(thisEntry, theEntry, sizeof(git_index_entry));
if (theEntry)
{
git_index_entry *thisEntry = self.git_index_entry;
memcpy(thisEntry, theEntry, sizeof(git_index_entry));
}
}
return self;
}
Expand Down

0 comments on commit d633d70

Please sign in to comment.