Skip to content

Commit

Permalink
Fix loading absolute path libs with LD_LIBRARY_PATH
Browse files Browse the repository at this point in the history
Commit 5aa5b08 changed the way
libraries are dynamically loaded when `LD_LIBRARY_PATH` is set to only
take the filename into account and not the complete path. This seems to
be overlooked code meant for testing as the commit is about video
testing and not library loading.

Revert the file to its previous state to fix loading libraries that are
specified with absolute paths.

Fixes GitHub issue KhronosGroup#479.
  • Loading branch information
Flakebi committed Oct 29, 2024
1 parent f674555 commit c00710e
Showing 1 changed file with 1 addition and 14 deletions.
15 changes: 1 addition & 14 deletions framework/delibs/deutil/deDynamicLibrary.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,6 @@
/* Posix implementation. */

#include <dlfcn.h>
#include <libgen.h>
#include <stdlib.h>

struct deDynamicLibrary_s
{
Expand All @@ -43,18 +41,7 @@ deDynamicLibrary *deDynamicLibrary_open(const char *fileName)
if (!library)
return NULL;

if (getenv("LD_LIBRARY_PATH"))
{
// basename() requires a non-const string because it may modify the its contents, so we cannot pass fileName to
// it directly. The string may be coming from statically allocated memory. E.g. this segfaulted in FreeBSD.
char *aux = deStrdup(fileName);
if (!aux)
return NULL;
library->libHandle = dlopen(basename(aux), RTLD_LAZY);
deFree(aux);
}
else
library->libHandle = dlopen(fileName, RTLD_LAZY);
library->libHandle = dlopen(fileName, RTLD_LAZY);

if (!library->libHandle)
{
Expand Down

0 comments on commit c00710e

Please sign in to comment.