rtld.c: avoid double-free on dso load failure in do_load_object()

The obj->path is assigned directly from the path argument, and
load_object() frees the path on do_load_object() failure.  Do not free
it in obj_free() on the error path.

Reviewed by:	markj
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D60402
This commit is contained in:
Konstantin Belousov committed 2026-10-06 20:33:27 +03:00
1 parent 4445d03958
commit 274236ed08
1 file changed
+1
+1
View File
@@ -3027,6 +3027,7 @@ do_load_object(int fd, const char *name, char *path, struct stat *sbp,
errp:
munmap(obj->mapbase, obj->mapsize);
obj->path = NULL; /* obj->path is owned and freed by caller */
obj_free(obj);
return (NULL);
}