From 1b88faf7aea53a72a4906f48ec30f16f1c157503 Mon Sep 17 00:00:00 2001 From: Russell Belfer Date: Thu, 3 Jan 2013 14:21:25 -0800 Subject: [PATCH] Fix oid tostr issue with NULL oid I made a small change to the behavior of this code and apparently got it wrong. Sigh. --- src/oid.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/oid.c b/src/oid.c index bbdd8541b..474129b58 100644 --- a/src/oid.c +++ b/src/oid.c @@ -100,7 +100,10 @@ char *git_oid_tostr(char *out, size_t n, const git_oid *oid) n--; /* allow room for terminating NUL */ - if (n > 0 && oid != NULL) { + if (oid == NULL) + n = 0; + + if (n > 0) { git_oid_fmt(str, oid); if (n > GIT_OID_HEXSZ) n = GIT_OID_HEXSZ;