From bab3d0330c7953d8b878a99e956b6955d893f48e Mon Sep 17 00:00:00 2001 From: midipix Date: Tue, 14 Aug 2018 03:15:56 -0400 Subject: slbt_lconf_open(): close all temporarily-opened directory file descriptors. --- src/internal/slibtool_lconf_impl.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/internal/slibtool_lconf_impl.c b/src/internal/slibtool_lconf_impl.c index c5f721a..691536d 100644 --- a/src/internal/slibtool_lconf_impl.c +++ b/src/internal/slibtool_lconf_impl.c @@ -61,17 +61,23 @@ static int slbt_lconf_open( if (fdparent < 0) return SLBT_SYSTEM_ERROR(dctx); - if (fstat(fdparent,&stparent) < 0) + if (fstat(fdparent,&stparent) < 0) { + close(fdparent); return SLBT_SYSTEM_ERROR(dctx); + } - if (stparent.st_dev != stcwd.st_dev) + if (stparent.st_dev != stcwd.st_dev) { + close(fdparent); return SLBT_CUSTOM_ERROR( dctx,SLBT_ERR_LCONF_OPEN); + } fdlconfdir = fdparent; fdlconf = openat(fdlconfdir,"libtool",O_RDONLY,0); } + slbt_lconf_close(fdcwd,fdlconfdir); + return fdlconf; } -- cgit v1.2.3