X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=combine-diff.c;h=bccc018ab2666e769e7865d3cad1d61f04443700;hb=5c38ea31f345d08f37685cf4f50c599a7af56bcf;hp=ec8df39bb01347eb035ad94553357b80af652b78;hpb=363cfc1716c9192053aaceb7e61e6a3af5699ddd;p=git.git diff --git a/combine-diff.c b/combine-diff.c index ec8df39bb..bccc018ab 100644 --- a/combine-diff.c +++ b/combine-diff.c @@ -703,15 +703,15 @@ static void show_patch_diff(struct combine_diff_path *elem, int num_parent, goto deleted_file; if (S_ISLNK(st.st_mode)) { - size_t len = xsize_t(st.st_size); - result_size = len; - result = xmalloc(len + 1); - if (result_size != readlink(elem->path, result, len)) { + struct strbuf buf = STRBUF_INIT; + + if (strbuf_readlink(&buf, elem->path, st.st_size) < 0) { error("readlink(%s): %s", elem->path, strerror(errno)); return; } - result[len] = 0; + result_size = buf.len; + result = strbuf_detach(&buf, NULL); elem->mode = canon_mode(st.st_mode); } else if (0 <= (fd = open(elem->path, O_RDONLY)) &&