From d06924baefe76d7e75fc2b31880643bab5e5c159 Mon Sep 17 00:00:00 2001 From: Rym Bouabid Date: Fri, 14 Jun 2024 15:25:26 +0200 Subject: [PATCH] qlibrary_unix.cpp: Make adding 'lib' prefix possible even when the file name starts with 'lib' Loading QLibrary("library_manager") and QLibrary("lib_example") is not possible if their binaries are called liblibrary_manager.so and liblib_examplep.so. Remove this prefix check: if (!prefixes.at(prefix).isEmpty() && name.startsWith(prefixes.at(prefix)) ,in order to allow calling dlopen() with "lib" prefix added to the name even if the name starts with "lib". The drawback of removing the check is that extra dlopen() calls will take place in other cases such as: "libexample.so". In this case we will have two extra calls of dlopen() taking "liblibexample.so" and "liblibexample". Fixes: QTBUG-23470 Pick-to: 6.7 6.5 6.2 Change-Id: I2c0b1b81edf8253443388aa67d24f4cd64d4123d Reviewed-by: Thiago Macieira (cherry picked from commit 2f11edad9e87311a977cb6edbd908a9fdd86a567) Reviewed-by: Qt Cherry-pick Bot --- src/corelib/plugin/qlibrary_unix.cpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/corelib/plugin/qlibrary_unix.cpp b/src/corelib/plugin/qlibrary_unix.cpp index 2edd71487d5..6d764f1ba1a 100644 --- a/src/corelib/plugin/qlibrary_unix.cpp +++ b/src/corelib/plugin/qlibrary_unix.cpp @@ -185,8 +185,6 @@ bool QLibraryPrivate::load_sys() Handle hnd = nullptr; for (int prefix = 0; retry && !hnd && prefix < prefixes.size(); prefix++) { for (int suffix = 0; retry && !hnd && suffix < suffixes.size(); suffix++) { - if (!prefixes.at(prefix).isEmpty() && name.startsWith(prefixes.at(prefix))) - continue; if (path.isEmpty() && prefixes.at(prefix).contains(u'/')) continue; if (!suffixes.at(suffix).isEmpty() && name.endsWith(suffixes.at(suffix)))