summaryrefslogtreecommitdiff
path: root/sha1_file.c
diff options
context:
space:
mode:
authorRene Scharfe <l.s.r@web.de>2017-08-30 18:00:29 (GMT)
committerJunio C Hamano <gitster@pobox.com>2017-09-06 23:49:28 (GMT)
commitea8e029785f87dc167491ebbc7ea3e924a72b5c4 (patch)
tree3e66a35a1cc382e94078c6c3e8a04197dbb6bc7f /sha1_file.c
parent872d651f528443efa5586a2d81a7629448545f61 (diff)
downloadgit-ea8e029785f87dc167491ebbc7ea3e924a72b5c4.zip
git-ea8e029785f87dc167491ebbc7ea3e924a72b5c4.tar.gz
git-ea8e029785f87dc167491ebbc7ea3e924a72b5c4.tar.bz2
sha1_file: release strbuf on error return in index_path()
strbuf_readlink() already frees the buffer for us on error. Clean up if write_sha1_file() fails as well instead of returning early. Signed-off-by: Rene Scharfe <l.s.r@web.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'sha1_file.c')
-rw-r--r--sha1_file.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/sha1_file.c b/sha1_file.c
index f56bb5c..7d9c9ae 100644
--- a/sha1_file.c
+++ b/sha1_file.c
@@ -1820,6 +1820,7 @@ int index_path(struct object_id *oid, const char *path, struct stat *st, unsigne
{
int fd;
struct strbuf sb = STRBUF_INIT;
+ int rc = 0;
switch (st->st_mode & S_IFMT) {
case S_IFREG:
@@ -1836,8 +1837,7 @@ int index_path(struct object_id *oid, const char *path, struct stat *st, unsigne
if (!(flags & HASH_WRITE_OBJECT))
hash_sha1_file(sb.buf, sb.len, blob_type, oid->hash);
else if (write_sha1_file(sb.buf, sb.len, blob_type, oid->hash))
- return error("%s: failed to insert into database",
- path);
+ rc = error("%s: failed to insert into database", path);
strbuf_release(&sb);
break;
case S_IFDIR:
@@ -1845,7 +1845,7 @@ int index_path(struct object_id *oid, const char *path, struct stat *st, unsigne
default:
return error("%s: unsupported file type", path);
}
- return 0;
+ return rc;
}
int read_pack_header(int fd, struct pack_header *header)