summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSven Strickroth <email@cs-ware.de>2012-11-24 15:48:17 +0100
committerSven Strickroth <email@cs-ware.de>2012-11-24 15:50:51 +0100
commitfcb48e068028da7b8cb60ac3954f3e9f5fc38390 (patch)
tree0ec56cf97fb7e68e7c95377120af5e7a60a926b1
parentc4d8df27bc4d3c0ef5ea46f4953614955fc4bdc2 (diff)
downloadlibgit2-fcb48e068028da7b8cb60ac3954f3e9f5fc38390.tar.gz
Set p->mwf.fd to -1 on error
If p->mwf.fd is e.g. -2 then it is closed in packfile_free and an exception might be thrown. Signed-off-by: Sven Strickroth <email@cs-ware.de>
-rw-r--r--src/pack.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/src/pack.c b/src/pack.c
index f08f3d8c4..a2a2fbcd1 100644
--- a/src/pack.c
+++ b/src/pack.c
@@ -564,8 +564,10 @@ static int packfile_open(struct git_pack_file *p)
/* TODO: open with noatime */
p->mwf.fd = git_futils_open_ro(p->pack_name);
- if (p->mwf.fd < 0)
- return p->mwf.fd;
+ if (p->mwf.fd < 0) {
+ p->mwf.fd = -1;
+ return -1;
+ }
if (p_fstat(p->mwf.fd, &st) < 0 ||
git_mwindow_file_register(&p->mwf) < 0)