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)`.
This commit is contained in:
drew-wells 2023-03-21 10:10:19 +00:00 committed by GitHub
parent 6eac424e5e
commit 9aaf2b7526
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
Notes: git 2023-03-21 10:10:41 +00:00
Merged: https://github.com/ruby/ruby/pull/7552

Merged-By: nobu <nobu@ruby-lang.org>

6
dln.c
View File

@ -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);