Skip to content

Commit

Permalink
Correct prepending of injector lib path to preload env var
Browse files Browse the repository at this point in the history
The dynamic loader on OS X does not like empty elements
in the list
  • Loading branch information
Robert Knight committed Nov 8, 2013
1 parent 621b64c commit 774b66f
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions PreloadInjector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 28,14 @@ bool PreloadInjector::startAndInject(const QString& program, const QStringList&

#ifdef Q_OS_MAC
QString var = "DYLD_INSERT_LIBRARIES";
QString value = env.value(var);
env.insert(var, QString("%1:%2").arg(libraryPath).arg(value));
QStringList currentLibs = env.value(var).split(':');
currentLibs.prepend(libraryPath);
env.insert(var, currentLibs.join(":"));
#elif defined(Q_OS_LINUX)
QString var = "LD_PRELOAD";
QString value = env.value(var);
env.insert(var, QString("%1 %2").arg(libraryPath).arg(value));
QStringList currentLibs = env.value(var).split(' ');
currentLibs.prepend(libraryPath);
env.insert(var, currentLibs.join(" "));
#else
#error Platform not supported
#endif
Expand Down

0 comments on commit 774b66f

Please sign in to comment.