diff options
author | Russell Belfer <rb@github.com> | 2012-12-20 03:06:14 +0400 |
---|---|---|
committer | Russell Belfer <rb@github.com> | 2013-01-05 03:47:42 +0400 |
commit | 8fe713ccf7bf8c6330fdda7f0c733e7f3ab29d3f (patch) | |
tree | afb53ab99c90d710cd31fa9bb21cf03c059778b9 /src/oid.c | |
parent | 5cf9875a4f6ee6fa26f5617aca8433dd49c72751 (diff) |
Make git_oid_tostr use out buffer for NULL oid
Previously a NULL oid was handled like an empty buffer and
returned a status empty string. This makes git_oid_tostr()
set the output buffer to the empty string instead.
Diffstat (limited to 'src/oid.c')
-rw-r--r-- | src/oid.c | 4 |
1 files changed, 2 insertions, 2 deletions
@@ -95,12 +95,12 @@ char *git_oid_tostr(char *out, size_t n, const git_oid *oid) { char str[GIT_OID_HEXSZ]; - if (!out || n == 0 || !oid) + if (!out || n == 0) return ""; n--; /* allow room for terminating NUL */ - if (n > 0) { + if (n > 0 && oid != NULL) { git_oid_fmt(str, oid); if (n > GIT_OID_HEXSZ) n = GIT_OID_HEXSZ; |