diff options
author | Vicent Marti <tanoku@gmail.com> | 2011-08-18 02:13:51 +0200 |
---|---|---|
committer | Vicent Marti <tanoku@gmail.com> | 2011-08-18 02:35:28 +0200 |
commit | 84dd3820d41046d35cb8b3bf65e67d0eb7e68f6c (patch) | |
tree | 9a9f028446162d5effe4f5458f60c9bdb628f81a /src/odb.c | |
parent | c85e08b1bda30c1a7e0a6e804f81665047fd8005 (diff) | |
download | libgit2-84dd3820d41046d35cb8b3bf65e67d0eb7e68f6c.tar.gz |
posix: Properly handle `snprintf` in all platforms
Diffstat (limited to 'src/odb.c')
-rw-r--r-- | src/odb.c | 6 |
1 files changed, 2 insertions, 4 deletions
@@ -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; } |