Skip to content

Commit a0e1336

Browse files
committed
Fixed some bugs where a NULL dereference could occur.
1 parent 0774e09 commit a0e1336

File tree

1 file changed

+15
-5
lines changed

1 file changed

+15
-5
lines changed

PBGitTree.m

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,9 @@ - (NSString *) blame:(NSError **)anError
131131
if(error==nil){
132132
res=[repository outputInWorkdirForArguments:[NSArray arrayWithObjects:@"blame", @"-p", sha, @"--", [self fullPath], nil]];
133133
}else{
134-
*anError = [NSError errorWithDomain:@"blame" code:1 userInfo:[NSDictionary dictionaryWithObjectsAndKeys:error,NSLocalizedDescriptionKey,nil]];
134+
if (anError != NULL) {
135+
*anError = [NSError errorWithDomain:@"blame" code:1 userInfo:[NSDictionary dictionaryWithObjectsAndKeys:error,NSLocalizedDescriptionKey,nil]];
136+
}
135137
}
136138

137139
return res;
@@ -147,7 +149,9 @@ - (NSString *) log:(NSString *)format error:(NSError **)anError
147149
if(error==nil){
148150
res=[repository outputInWorkdirForArguments:[NSArray arrayWithObjects:@"log", [NSString stringWithFormat:@"--pretty=format:%@",format], @"--", [self fullPath], nil]];
149151
}else{
150-
*anError = [NSError errorWithDomain:@"log" code:1 userInfo:[NSDictionary dictionaryWithObjectsAndKeys:error,NSLocalizedDescriptionKey,nil]];
152+
if (anError != NULL) {
153+
*anError = [NSError errorWithDomain:@"log" code:1 userInfo:[NSDictionary dictionaryWithObjectsAndKeys:error,NSLocalizedDescriptionKey,nil]];
154+
}
151155
}
152156

153157
return res;
@@ -178,12 +182,16 @@ - (NSString *) diff:(NSString *)format error:(NSError **)anError
178182
res=[repository outputInWorkdirForArguments:[NSArray arrayWithObjects:@"diff", sha, des,[self fullPath], nil]];
179183
if ([res length]==0) {
180184
NSLog(@"--%d",[res length]);
181-
*anError = [NSError errorWithDomain:@"diff" code:1 userInfo:[NSDictionary dictionaryWithObjectsAndKeys:@"No Diff",NSLocalizedDescriptionKey,nil]];
185+
if (anError != NULL) {
186+
*anError = [NSError errorWithDomain:@"diff" code:1 userInfo:[NSDictionary dictionaryWithObjectsAndKeys:@"No Diff",NSLocalizedDescriptionKey,nil]];
187+
}
182188
}else{
183189
NSLog(@"--%@",[res substringToIndex:80]);
184190
}
185191
}else{
186-
*anError = [NSError errorWithDomain:@"diff" code:1 userInfo:[NSDictionary dictionaryWithObjectsAndKeys:error,NSLocalizedDescriptionKey,nil]];
192+
if (anError != NULL) {
193+
*anError = [NSError errorWithDomain:@"diff" code:1 userInfo:[NSDictionary dictionaryWithObjectsAndKeys:error,NSLocalizedDescriptionKey,nil]];
194+
}
187195
}
188196

189197
return res;
@@ -205,7 +213,9 @@ - (NSString *)textContents:(NSError **)anError
205213
if(error==nil){
206214
res = [self contents];
207215
}else{
208-
*anError = [NSError errorWithDomain:@"show" code:1 userInfo:[NSDictionary dictionaryWithObjectsAndKeys:error,NSLocalizedDescriptionKey,nil]];
216+
if (anError != NULL) {
217+
*anError = [NSError errorWithDomain:@"show" code:1 userInfo:[NSDictionary dictionaryWithObjectsAndKeys:error,NSLocalizedDescriptionKey,nil]];
218+
}
209219
}
210220

211221
return res;

0 commit comments

Comments
 (0)