Skip to content

Commit e4c2971

Browse files
committed
fix random log output
the char array returned by git_oid_fmt isn't null terminated and then passed to a format specifier with %s. Output is thus the SHA + gargabe until a \0 is found. Fix it by increasing the array by 1 and using git_oid_tostr which adds a \0.
1 parent e5faba2 commit e4c2971

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

Classes/GTRepository.m

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -217,8 +217,8 @@ - (id)lookupObjectByGitOid:(const git_oid *)oid objectType:(GTObjectType)type er
217217
int gitError = git_object_lookup(&obj, self.git_repository, oid, (git_otype)type);
218218
if (gitError < GIT_OK) {
219219
if (error != NULL) {
220-
char oid_str[GIT_OID_HEXSZ];
221-
git_oid_fmt(oid_str, oid);
220+
char oid_str[GIT_OID_HEXSZ+1];
221+
git_oid_tostr(oid_str, sizeof(oid_str), oid);
222222
*error = [NSError git_errorFor:gitError withAdditionalDescription:@"Failed to lookup object %s in repository.", oid_str];
223223
}
224224
return nil;

0 commit comments

Comments
 (0)