summaryrefslogtreecommitdiff
path: root/combine-diff.c
diff options
context:
space:
mode:
authorLibravatar Junio C Hamano <gitster@pobox.com>2017-04-16 23:29:26 -0700
committerLibravatar Junio C Hamano <gitster@pobox.com>2017-04-16 23:29:26 -0700
commitcb054eb26452e07a3cb34703e1579b97f5c7e6ab (patch)
treebdb83f6ceb82421f173934431c1299dc167dbd06 /combine-diff.c
parentEleventh batch for 2.13 (diff)
parentdaemon: use an argv_array to exec children (diff)
downloadtgif-cb054eb26452e07a3cb34703e1579b97f5c7e6ab.tar.xz
Merge branch 'jk/snprintf-cleanups'
Code clean-up. * jk/snprintf-cleanups: daemon: use an argv_array to exec children gc: replace local buffer with git_path transport-helper: replace checked snprintf with xsnprintf convert unchecked snprintf into xsnprintf combine-diff: replace malloc/snprintf with xstrfmt replace unchecked snprintf calls with heap buffers receive-pack: print --pack-header directly into argv array name-rev: replace static buffer with strbuf create_branch: use xstrfmt for reflog message create_branch: move msg setup closer to point of use avoid using mksnpath for refs avoid using fixed PATH_MAX buffers for refs fetch: use heap buffer to format reflog tag: use strbuf to format tag header diff: avoid fixed-size buffer for patch-ids odb_mkstemp: use git_path_buf odb_mkstemp: write filename into strbuf do not check odb_mkstemp return value for errors
Diffstat (limited to 'combine-diff.c')
-rw-r--r--combine-diff.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/combine-diff.c b/combine-diff.c
index 59501db99a..d3560573ac 100644
--- a/combine-diff.c
+++ b/combine-diff.c
@@ -292,9 +292,10 @@ static char *grab_blob(const struct object_id *oid, unsigned int mode,
enum object_type type;
if (S_ISGITLINK(mode)) {
- blob = xmalloc(100);
- *size = snprintf(blob, 100,
- "Subproject commit %s\n", oid_to_hex(oid));
+ struct strbuf buf = STRBUF_INIT;
+ strbuf_addf(&buf, "Subproject commit %s\n", oid_to_hex(oid));
+ *size = buf.len;
+ blob = strbuf_detach(&buf, NULL);
} else if (is_null_oid(oid)) {
/* deleted blob */
*size = 0;