git: 1545d8732d2e - stable/13 - fdlopen(3): do not create a new object mapping if already loaded

From: Konstantin Belousov <kib_at_FreeBSD.org>
Date: Thu, 29 Feb 2024 00:26:18 UTC
The branch stable/13 has been updated by kib:

URL: https://cgit.FreeBSD.org/src/commit/?id=1545d8732d2e076d085c08a13d3b6fc981b7f7fb

commit 1545d8732d2e076d085c08a13d3b6fc981b7f7fb
Author:     Konstantin Belousov <kib@FreeBSD.org>
AuthorDate: 2024-02-22 01:18:06 +0000
Commit:     Konstantin Belousov <kib@FreeBSD.org>
CommitDate: 2024-02-29 00:24:43 +0000

    fdlopen(3): do not create a new object mapping if already loaded
    
    PR:     277169
    
    (cherry picked from commit 452c5e9995ab4cd6c7ea230cffe0c53bfa65c1ab)
---
 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 3ef686441fab..e66e2f7f0f3b 100644
--- a/libexec/rtld-elf/rtld.c
+++ b/libexec/rtld-elf/rtld.c
@@ -2786,8 +2786,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);