refs API: don't expose "errno" in run_transaction_hook()
In run_transaction_hook() we've checked errno since 67541597670 (refs: implement reference transaction hook, 2020-06-19), let's reset errno afterwards to make sure nobody using refs.c directly or indirectly relies on it. Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Ævar Arnfjörð Bjarmason committed
Oct 16, 2021 at 11:39 UTC
4755d7dff7a27f431493926541fd6aab2e860aa4
1 file changed
+4
-1
refs.c
+4
-1
@@ -2096,8 +2096,11 @@ static int run_transaction_hook(struct ref_transaction *transaction,
2096
update->refname);
2097
2098
if (write_in_full(proc.in, buf.buf, buf.len) < 0) {
2099
- if (errno != EPIPE)
2099
+ if (errno != EPIPE) {
2100
+ /* Don't leak errno outside this API */
2101
+ errno = 0;
2102
ret = -1;
2103
+ }
2104
break;
2105
}
2106
}