From 9aaf2b752685f9e11b28fbe647289f12d75d9f5e Mon Sep 17 00:00:00 2001 From: drew-wells <58978640+drew-wells@users.noreply.github.com> Date: Tue, 21 Mar 2023 10:10:19 +0000 Subject: Update dln.c to fix error output from `dln_open()` `libruby_name` gets trashed by `dlclose(handle)`, so output the "linked to incompatible ... " error before calling `dlclose(handle)`. --- dln.c | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'dln.c') diff --git a/dln.c b/dln.c index 0edd709bbe..77bfe91b28 100644 --- a/dln.c +++ b/dln.c @@ -392,6 +392,12 @@ dln_open(const char *file) dln_fatalerror("%s - %s", incompatible, file); } else { + if (libruby_name) { + const size_t len = strlen(libruby_name); + char *const tmp = ALLOCA_N(char, len + 1); + if (tmp) memcpy(tmp, libruby_name, len + 1); + libruby_name = tmp; + } dlclose(handle); if (libruby_name) { dln_loaderror("linked to incompatible %s - %s", libruby_name, file); -- cgit v1.2.1