diff options
author | raymes@chromium.org <raymes@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-10-06 02:06:21 +0000 |
---|---|---|
committer | raymes@chromium.org <raymes@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-10-06 02:06:21 +0000 |
commit | ecac5739b92ef9668e9361c7af69ac0a04837f0b (patch) | |
tree | 612d994599f7888d0d5e88341e723f44f509ddff /ppapi | |
parent | 32e8fcbe44ebbaf51a724cd3575a8cb8416c4033 (diff) | |
download | chromium_src-ecac5739b92ef9668e9361c7af69ac0a04837f0b.zip chromium_src-ecac5739b92ef9668e9361c7af69ac0a04837f0b.tar.gz chromium_src-ecac5739b92ef9668e9361c7af69ac0a04837f0b.tar.bz2 |
Copy PP_Vars in ppapi test PluginVectorReceiveInput so we can test their refcount.
Previously when |SerializedVarVectorReceiveInput| objects went out of scope,
their associated arrays were destroyed which led to use-after-frees when
testing refcounts. This corrects the problem by making a copy of the array.
BUG=152298
TEST=valgrinded the test
Review URL: https://chromiumcodereview.appspot.com/11040051
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@160545 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ppapi')
-rw-r--r-- | ppapi/proxy/serialized_var_unittest.cc | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/ppapi/proxy/serialized_var_unittest.cc b/ppapi/proxy/serialized_var_unittest.cc index 16155a7..fcde777 100644 --- a/ppapi/proxy/serialized_var_unittest.cc +++ b/ppapi/proxy/serialized_var_unittest.cc @@ -201,12 +201,12 @@ TEST_F(SerializedVarTest, PluginReceiveInput) { // Tests the case that the plugin receives the same vars twice as an input // parameter (not passing ownership) within a vector. -TEST_F(SerializedVarTest, DISABLED_PluginVectorReceiveInput) { +TEST_F(SerializedVarTest, PluginVectorReceiveInput) { ProxyAutoLock lock; PP_Var host_object = MakeObjectVar(0x31337); - PP_Var* plugin_objects; - PP_Var* plugin_objects2; + std::vector<PP_Var> plugin_objects; + std::vector<PP_Var> plugin_objects2; { // Receive the params. The object should be tracked with no refcount and // no messages sent. The string should is plugin-side only and should have @@ -216,7 +216,10 @@ TEST_F(SerializedVarTest, DISABLED_PluginVectorReceiveInput) { input1.push_back(SerializedVarTestConstructor("elite")); SerializedVarVectorReceiveInput receive_input(input1); uint32_t array_size = 0; - plugin_objects = receive_input.Get(plugin_dispatcher(), &array_size); + PP_Var* plugin_objects_array = + receive_input.Get(plugin_dispatcher(), &array_size); + plugin_objects.insert(plugin_objects.begin(), plugin_objects_array, + plugin_objects_array + array_size); ASSERT_EQ(2u, array_size); EXPECT_EQ(0, var_tracker().GetRefCountForObject(plugin_objects[0])); EXPECT_EQ(1, var_tracker().GetRefCountForObject(plugin_objects[1])); @@ -229,7 +232,10 @@ TEST_F(SerializedVarTest, DISABLED_PluginVectorReceiveInput) { input2.push_back(SerializedVarTestConstructor("elite")); SerializedVarVectorReceiveInput receive_input2(input2); uint32_t array_size2 = 0; - plugin_objects2 = receive_input2.Get(plugin_dispatcher(), &array_size2); + PP_Var* plugin_objects_array2 = + receive_input2.Get(plugin_dispatcher(), &array_size2); + plugin_objects2.insert(plugin_objects2.begin(), plugin_objects_array2, + plugin_objects_array2 + array_size2); ASSERT_EQ(2u, array_size2); EXPECT_EQ(plugin_objects[0].value.as_id, plugin_objects2[0].value.as_id); EXPECT_EQ(0, var_tracker().GetRefCountForObject(plugin_objects[0])); |