diff options
author | 2018-03-02 16:37:18 -0800 | |
---|---|---|
committer | 2018-03-02 16:38:45 -0800 | |
commit | 443a6a5d7bb17443fd3c1ead930a90753eacfd65 (patch) | |
tree | 789480f84a370c1f85d17c1a793ca8254c2161a1 | |
parent | a2d18b7072158af6b1fb9260bbf4f5510c3def1d (diff) |
Ensure loaded plugins are not copied.
If a loaded plugin was copied we would try to initialize it a second
time. This would happen if you were running on a libartd.so because
the compiler would not select the move constructor since it wasn't
marked as noexcept.
Bug: 74125483
Test: Run dexmaker tests on a libartd runtime.
Change-Id: If86e4d3ed8fc68fce7295fb3779cb46499f9c72c
-rw-r--r-- | runtime/plugin.cc | 5 | ||||
-rw-r--r-- | runtime/plugin.h | 2 |
2 files changed, 2 insertions, 5 deletions
diff --git a/runtime/plugin.cc b/runtime/plugin.cc index 7d86f1d5dc..6f1c5179f9 100644 --- a/runtime/plugin.cc +++ b/runtime/plugin.cc @@ -28,10 +28,7 @@ const char* PLUGIN_INITIALIZATION_FUNCTION_NAME = "ArtPlugin_Initialize"; const char* PLUGIN_DEINITIALIZATION_FUNCTION_NAME = "ArtPlugin_Deinitialize"; Plugin::Plugin(const Plugin& other) : library_(other.library_), dlopen_handle_(nullptr) { - if (other.IsLoaded()) { - std::string err; - Load(&err); - } + CHECK(!other.IsLoaded()) << "Should not copy loaded plugins."; } bool Plugin::Load(/*out*/std::string* error_msg) { diff --git a/runtime/plugin.h b/runtime/plugin.h index 909c710a96..4885b2e3c0 100644 --- a/runtime/plugin.h +++ b/runtime/plugin.h @@ -60,7 +60,7 @@ class Plugin { Plugin(const Plugin& other); // Create move constructor for putting this in a list - Plugin(Plugin&& other) + Plugin(Plugin&& other) noexcept : library_(other.library_), dlopen_handle_(other.dlopen_handle_) { other.dlopen_handle_ = nullptr; |