From: jsg Date: Thu, 15 Feb 2024 00:55:01 +0000 (+0000) Subject: fix fd leaks in error paths X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=b15051c7b8d73cab4d6f122506c402d091fc74fb;p=openbsd fix fd leaks in error paths ok miod@ --- diff --git a/usr.bin/vi/common/exf.c b/usr.bin/vi/common/exf.c index 9b62d32e045..fa4fff1899e 100644 --- a/usr.bin/vi/common/exf.c +++ b/usr.bin/vi/common/exf.c @@ -1,4 +1,4 @@ -/* $OpenBSD: exf.c,v 1.49 2024/02/14 03:07:58 jsg Exp $ */ +/* $OpenBSD: exf.c,v 1.50 2024/02/15 00:55:01 jsg Exp $ */ /*- * Copyright (c) 1992, 1993, 1994 @@ -853,8 +853,10 @@ file_write(SCR *sp, MARK *fm, MARK *tm, char *name, int flags) from.lno = 1; from.cno = 0; fm = &from; - if (db_last(sp, &to.lno)) + if (db_last(sp, &to.lno)) { + (void)fclose(fp); return (1); + } to.cno = 0; tm = &to; } @@ -1017,8 +1019,10 @@ file_backup(SCR *sp, char *name, char *bname) ++bname; } else version = 0; - if (argv_exp2(sp, &cmd, bname, strlen(bname))) + if (argv_exp2(sp, &cmd, bname, strlen(bname))) { + (void)close(rfd); return (1); + } /* * 0 args: impossible.