From: Mike Yuan Date: Tue, 25 Nov 2025 02:52:57 +0000 (+0100) Subject: dlfcn-util: fix potential dl handle leak X-Git-Tag: v259-rc2~6^2~3 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=f76f91b7c99574b3e7120f0dd008b2ab703efc47;p=thirdparty%2Fsystemd.git dlfcn-util: fix potential dl handle leak Follow-up for 2c7bdaf9f144ad339c72628579183fc849f2b794 --- diff --git a/src/basic/dlfcn-util.c b/src/basic/dlfcn-util.c index 26c5a44ffe0..8574e99546b 100644 --- a/src/basic/dlfcn-util.c +++ b/src/basic/dlfcn-util.c @@ -84,6 +84,7 @@ void block_dlopen(void) { } int dlopen_safe(const char *filename, void **ret, const char **reterr_dlerror) { + _cleanup_(dlclosep) void *dl = NULL; int r; assert(filename); @@ -99,8 +100,8 @@ int dlopen_safe(const char *filename, void **ret, const char **reterr_dlerror) { flags |= RTLD_NOLOAD; errno = 0; - void *p = dlopen(filename, flags); - if (!p) { + dl = dlopen(filename, flags); + if (!dl) { if (dlopen_blocked) { (void) dlerror(); /* consume error, so that no later call will return it */ @@ -121,7 +122,7 @@ int dlopen_safe(const char *filename, void **ret, const char **reterr_dlerror) { } if (ret) - *ret = TAKE_PTR(p); + *ret = TAKE_PTR(dl); return 0; }