Andrew's git
/
gitweb.git
/ diff
summary
|
log
|
commit
| diff |
tree
commit
grep
author
committer
pickaxe
?
re
sha1_file: release strbuf on error return in index_path()
author
Rene Scharfe
<l.s.r@web.de>
Wed, 30 Aug 2017 18:00:29 +0000
(20:00 +0200)
committer
Junio C Hamano
<gitster@pobox.com>
Wed, 6 Sep 2017 23:49:28 +0000
(08:49 +0900)
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>
sha1_file.c
patch
|
blob
|
history
raw
|
patch
|
inline
| side by side (parent:
872d651
)
diff --git
a/sha1_file.c
b/sha1_file.c
index f56bb5cae7ba5aed095bff90672b24c616cbcf54..7d9c9aed2f5c5483771ff7ab90f53cd9870402c0 100644
(file)
--- 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 fd;
struct strbuf sb = STRBUF_INIT;
+ int rc = 0;
switch (st->st_mode & S_IFMT) {
case S_IFREG:
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))
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:
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);
}
default:
return error("%s: unsupported file type", path);
}
- return
0
;
+ return
rc
;
}
int read_pack_header(int fd, struct pack_header *header)
}
int read_pack_header(int fd, struct pack_header *header)