Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(344)

Side by Side Diff: content/renderer/pepper/plugin_object.cc

Issue 324033002: Fix the leak of the wrapper created by WrapperClass_Allocate(). (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "content/renderer/pepper/plugin_object.h" 5 #include "content/renderer/pepper/plugin_object.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "base/memory/ref_counted.h" 8 #include "base/memory/ref_counted.h"
9 #include "base/memory/scoped_ptr.h" 9 #include "base/memory/scoped_ptr.h"
10 #include "base/strings/string_number_conversions.h" 10 #include "base/strings/string_number_conversions.h"
(...skipping 25 matching lines...) Expand all
36 const char kInvalidValueException[] = "Error: Invalid value"; 36 const char kInvalidValueException[] = "Error: Invalid value";
37 37
38 // NPObject implementation in terms of PPP_Class_Deprecated -------------------- 38 // NPObject implementation in terms of PPP_Class_Deprecated --------------------
39 39
40 NPObject* WrapperClass_Allocate(NPP npp, NPClass* unused) { 40 NPObject* WrapperClass_Allocate(NPP npp, NPClass* unused) {
41 return PluginObject::AllocateObjectWrapper(); 41 return PluginObject::AllocateObjectWrapper();
42 } 42 }
43 43
44 void WrapperClass_Deallocate(NPObject* np_object) { 44 void WrapperClass_Deallocate(NPObject* np_object) {
45 PluginObject* plugin_object = PluginObject::FromNPObject(np_object); 45 PluginObject* plugin_object = PluginObject::FromNPObject(np_object);
46 if (!plugin_object) 46 if (plugin_object) {
47 return; 47 plugin_object->ppp_class()->Deallocate(plugin_object->ppp_class_data());
48 plugin_object->ppp_class()->Deallocate(plugin_object->ppp_class_data()); 48 delete plugin_object;
49 delete plugin_object; 49 }
50 delete np_object;
brettw 2014/06/16 19:36:50 Sorry I don't have in my head how this is supposed
Lei Zhang 2014/06/16 20:37:30 I'm not deleting it when FromNPObject() fails. I'm
50 } 51 }
51 52
52 void WrapperClass_Invalidate(NPObject* object) {} 53 void WrapperClass_Invalidate(NPObject* object) {}
53 54
54 bool WrapperClass_HasMethod(NPObject* object, NPIdentifier method_name) { 55 bool WrapperClass_HasMethod(NPObject* object, NPIdentifier method_name) {
55 NPObjectAccessorWithIdentifier accessor(object, method_name, false); 56 NPObjectAccessorWithIdentifier accessor(object, method_name, false);
56 if (!accessor.is_valid()) 57 if (!accessor.is_valid())
57 return false; 58 return false;
58 59
59 PPResultAndExceptionToNPResult result_converter( 60 PPResultAndExceptionToNPResult result_converter(
(...skipping 296 matching lines...) Expand 10 before | Expand all | Expand 10 after
356 } 357 }
357 358
358 // static 359 // static
359 NPObject* PluginObject::AllocateObjectWrapper() { 360 NPObject* PluginObject::AllocateObjectWrapper() {
360 NPObjectWrapper* wrapper = new NPObjectWrapper; 361 NPObjectWrapper* wrapper = new NPObjectWrapper;
361 memset(wrapper, 0, sizeof(NPObjectWrapper)); 362 memset(wrapper, 0, sizeof(NPObjectWrapper));
362 return wrapper; 363 return wrapper;
363 } 364 }
364 365
365 } // namespace content 366 } // namespace content
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698