Skip to content

Commit

Permalink
Update dln.c to fix error output from dln_open()
Browse files Browse the repository at this point in the history
`libruby_name` gets trashed by `dlclose(handle)`, so output the
"linked to incompatible ... " error before calling `dlclose(handle)`.
  • Loading branch information
drew-wells authored Mar 21, 2023
1 parent 6eac424 commit 9aaf2b7
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions dln.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 9aaf2b7

Please sign in to comment.