From 452c5e9995ab4cd6c7ea230cffe0c53bfa65c1ab Mon Sep 17 00:00:00 2001 From: Konstantin Belousov Date: Thu, 22 Feb 2024 03:18:06 +0200 Subject: [PATCH] fdlopen(3): do not create a new object mapping if already loaded This is expected behavior for both dlopen(3) and fdlopen(3). PR: 277169 Reviewed by: emaste Sponsored by: The FreeBSD Foundation MFC after: 1 week Differential revision: https://reviews.freebsd.org/D44019 --- libexec/rtld-elf/rtld.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/libexec/rtld-elf/rtld.c b/libexec/rtld-elf/rtld.c index 7d6b8ae5270..30ed48b5c61 100644 --- a/libexec/rtld-elf/rtld.c +++ b/libexec/rtld-elf/rtld.c @@ -2752,8 +2752,9 @@ load_object(const char *name, int fd_u, const Obj_Entry *refobj, int flags) if (obj->ino == sb.st_ino && obj->dev == sb.st_dev) break; } - if (obj != NULL && name != NULL) { - object_add_name(obj, name); + if (obj != NULL) { + if (name != NULL) + object_add_name(obj, name); free(path); close(fd); return (obj);