summaryrefslogtreecommitdiff
path: root/src/odb.c
diff options
context:
space:
mode:
authorVicent Marti <tanoku@gmail.com>2011-08-18 02:13:51 +0200
committerVicent Marti <tanoku@gmail.com>2011-08-18 02:35:28 +0200
commit84dd3820d41046d35cb8b3bf65e67d0eb7e68f6c (patch)
tree9a9f028446162d5effe4f5458f60c9bdb628f81a /src/odb.c
parentc85e08b1bda30c1a7e0a6e804f81665047fd8005 (diff)
downloadlibgit2-84dd3820d41046d35cb8b3bf65e67d0eb7e68f6c.tar.gz
posix: Properly handle `snprintf` in all platforms
Diffstat (limited to 'src/odb.c')
-rw-r--r--src/odb.c6
1 files changed, 2 insertions, 4 deletions
diff --git a/src/odb.c b/src/odb.c
index fcba4fc71..ec81cdacb 100644
--- a/src/odb.c
+++ b/src/odb.c
@@ -49,13 +49,11 @@ typedef struct
static int format_object_header(char *hdr, size_t n, size_t obj_len, git_otype obj_type)
{
const char *type_str = git_object_type2string(obj_type);
- int len = snprintf(hdr, n, "%s %"PRIuZ, type_str, obj_len);
-
- assert(len > 0); /* otherwise snprintf() is broken */
- assert(((size_t) len) < n); /* otherwise the caller is broken! */
+ int len = p_snprintf(hdr, n, "%s %"PRIuZ, type_str, obj_len);
if (len < 0 || ((size_t) len) >= n)
return git__throw(GIT_ERROR, "Cannot format object header. Length is out of bounds");
+
return len+1;
}