summaryrefslogtreecommitdiffstats
path: root/src/corelib/plugin
diff options
context:
space:
mode:
Diffstat (limited to 'src/corelib/plugin')
-rw-r--r--src/corelib/plugin/qlibrary.cpp29
-rw-r--r--src/corelib/plugin/qlibrary_unix.cpp35
2 files changed, 23 insertions, 41 deletions
diff --git a/src/corelib/plugin/qlibrary.cpp b/src/corelib/plugin/qlibrary.cpp
index bca6918b4a..a3b8be8911 100644
--- a/src/corelib/plugin/qlibrary.cpp
+++ b/src/corelib/plugin/qlibrary.cpp
@@ -239,21 +239,34 @@ static bool findPatternUnloaded(const QString &library, QLibraryPrivate *lib)
if (lib)
lib->errorString = file.errorString();
if (qt_debug_component()) {
- qWarning("%s: %s", (const char*) QFile::encodeName(library),
+ qWarning("%s: %s", QFile::encodeName(library).constData(),
qPrintable(QSystemError::stdString()));
}
return false;
}
QByteArray data;
- const char *filedata = 0;
ulong fdlen = file.size();
- filedata = (char *) file.map(0, fdlen);
+ const char *filedata = reinterpret_cast<char *>(file.map(0, fdlen));
+
if (filedata == 0) {
- // try reading the data into memory instead
- data = file.readAll();
- filedata = data.constData();
- fdlen = data.size();
+ if (uchar *mapdata = file.map(0, 1)) {
+ file.unmap(mapdata);
+ // Mapping is supported, but failed for the entire file, likely due to OOM.
+ // Return false, as readAll() would cause a bad_alloc and terminate the process.
+ if (lib)
+ lib->errorString = QLibrary::tr("Out of memory while loading plugin '%1'.").arg(library);
+ if (qt_debug_component()) {
+ qWarning("%s: %s", QFile::encodeName(library).constData(),
+ qPrintable(QSystemError::stdString(ENOMEM)));
+ }
+ return false;
+ } else {
+ // Try reading the data into memory instead.
+ data = file.readAll();
+ filedata = data.constData();
+ fdlen = data.size();
+ }
}
/*
@@ -751,7 +764,7 @@ void QLibraryPrivate::updatePluginState()
if (qt_debug_component()) {
qWarning("In %s:\n"
" Plugin uses incompatible Qt library (%d.%d.%d) [%s]",
- (const char*) QFile::encodeName(fileName),
+ QFile::encodeName(fileName).constData(),
(qt_version&0xff0000) >> 16, (qt_version&0xff00) >> 8, qt_version&0xff,
debug ? "debug" : "release");
}
diff --git a/src/corelib/plugin/qlibrary_unix.cpp b/src/corelib/plugin/qlibrary_unix.cpp
index 3c4fbaf348..23b9ad6434 100644
--- a/src/corelib/plugin/qlibrary_unix.cpp
+++ b/src/corelib/plugin/qlibrary_unix.cpp
@@ -44,25 +44,17 @@
#include <qcoreapplication.h>
#include <private/qfilesystementry_p.h>
+#include <dlfcn.h>
+
#ifdef Q_OS_MAC
# include <private/qcore_mac_p.h>
#endif
QT_BEGIN_NAMESPACE
-#if !defined(QT_HPUX_LD)
-QT_BEGIN_INCLUDE_NAMESPACE
-#include <dlfcn.h>
-QT_END_INCLUDE_NAMESPACE
-#endif
-
static QString qdlerror()
{
-#if !defined(QT_HPUX_LD)
const char *err = dlerror();
-#else
- const char *err = strerror(errno);
-#endif
return err ? QLatin1Char('(') + QString::fromLocal8Bit(err) + QLatin1Char(')'): QString();
}
@@ -139,14 +131,6 @@ bool QLibraryPrivate::load_sys()
suffixes = suffixes_sys(fullVersion);
}
int dlFlags = 0;
-#if defined(QT_HPUX_LD)
- dlFlags = DYNAMIC_PATH | BIND_NONFATAL;
- if (loadHints & QLibrary::ResolveAllSymbolsHint) {
- dlFlags |= BIND_IMMEDIATE;
- } else {
- dlFlags |= BIND_DEFERRED;
- }
-#else
int loadHints = this->loadHints();
if (loadHints & QLibrary::ResolveAllSymbolsHint) {
dlFlags |= RTLD_NOW;
@@ -182,7 +166,6 @@ bool QLibraryPrivate::load_sys()
dlFlags |= RTLD_MEMBER;
}
#endif
-#endif // QT_HPUX_LD
// If the filename is an absolute path then we want to try that first as it is most likely
// what the callee wants. If we have been given a non-absolute path then lets try the
@@ -211,11 +194,7 @@ bool QLibraryPrivate::load_sys()
} else {
attempt = path + prefixes.at(prefix) + name + suffixes.at(suffix);
}
-#if defined(QT_HPUX_LD)
- pHnd = (void*)shl_load(QFile::encodeName(attempt), dlFlags, 0);
-#else
pHnd = dlopen(QFile::encodeName(attempt), dlFlags);
-#endif
if (!pHnd && fileName.startsWith(QLatin1Char('/')) && QFile::exists(attempt)) {
// We only want to continue if dlopen failed due to that the shared library did not exist.
@@ -253,11 +232,7 @@ bool QLibraryPrivate::load_sys()
bool QLibraryPrivate::unload_sys()
{
-#if defined(QT_HPUX_LD)
- if (shl_unload((shl_t)pHnd)) {
-#else
if (dlclose(pHnd)) {
-#endif
#if defined (Q_OS_QNX) // Workaround until fixed in QNX; fixes crash in
char *error = dlerror(); // QtDeclarative auto test "qqmlenginecleanup" for instance
if (!qstrcmp(error, "Shared objects still referenced")) // On QNX that's only "informative"
@@ -289,13 +264,7 @@ Q_CORE_EXPORT QFunctionPointer qt_mac_resolve_sys(void *handle, const char *symb
QFunctionPointer QLibraryPrivate::resolve_sys(const char* symbol)
{
-#if defined(QT_HPUX_LD)
- QFunctionPointer address = 0;
- if (shl_findsym((shl_t*)&pHnd, symbol, TYPE_UNDEFINED, &address) < 0)
- address = 0;
-#else
QFunctionPointer address = QFunctionPointer(dlsym(pHnd, symbol));
-#endif
if (!address) {
errorString = QLibrary::tr("Cannot resolve symbol \"%1\" in %2: %3").arg(
QString::fromLatin1(symbol), fileName, qdlerror());