summaryrefslogtreecommitdiffstats
path: root/src/plugins
diff options
context:
space:
mode:
authorThiago Macieira <thiago.macieira@intel.com>2016-12-09 16:53:30 -0800
committerThiago Macieira <thiago.macieira@intel.com>2016-12-17 04:11:09 +0000
commit7ca66b1e66e73a0cb35705df04507ef9f3440cab (patch)
tree390c66fa09fc6a3ed0a57ece00f12d6cdabc8a53 /src/plugins
parent8325808dcf0cc9061f05ec89b6c3e3afb8c1ab8f (diff)
Fix race condition in QFactoryLoader: lock the mutex we already have
The process of loading a plugin is examplified by the qLoadPlugin function (though not all users of QFactoryLoader use this function, they all do something similar): const int index = loader->indexOf(key); if (index != -1) { QObject *factoryObject = loader->instance(index); if (FactoryInterface *factory = qobject_cast<FactoryInterface *>(factoryObject)) if (PluginInterface *result = factory->create(key, std::forward<Args>(args)...)) return result; } QFactoryLoader::indexOf already locked the mutex, but not QFactoryLoader::instance. This commit fixes that. Note that calling the virtual create() in the plugin's factory is not protected by the mutex. Each plugin's factory must be thread-safe and also create an object that works on any thread too. It's also the responsibility of the caller of qLoadPlugin to ensure that it's called thread-safely. Task-number: QTBUG-42855 Change-Id: I63e21df51c7448bc8b5ffffd148ebee33d4c47de Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com> Reviewed-by: Marc Mutz <marc.mutz@kdab.com>
Diffstat (limited to 'src/plugins')
0 files changed, 0 insertions, 0 deletions