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

Side by Side Diff: fxjs/cfxjse_class.cpp

Issue 2328273004: Fix leaked value object in NamedPropertySetterCallback() (Closed)
Patch Set: Created 4 years, 3 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
« 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 2016 PDFium Authors. All rights reserved. 1 // Copyright 2016 PDFium 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 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
6 6
7 #include "fxjs/include/cfxjse_class.h" 7 #include "fxjs/include/cfxjse_class.h"
8 8
9 #include "fxjs/include/cfxjse_context.h" 9 #include "fxjs/include/cfxjse_context.h"
10 #include "fxjs/include/cfxjse_value.h" 10 #include "fxjs/include/cfxjse_value.h"
(...skipping 271 matching lines...) Expand 10 before | Expand all | Expand 10 after
282 const v8::PropertyCallbackInfo<v8::Value>& info) { 282 const v8::PropertyCallbackInfo<v8::Value>& info) {
283 v8::Local<v8::Object> thisObject = info.This(); 283 v8::Local<v8::Object> thisObject = info.This();
284 const FXJSE_CLASS_DESCRIPTOR* lpClass = static_cast<FXJSE_CLASS_DESCRIPTOR*>( 284 const FXJSE_CLASS_DESCRIPTOR* lpClass = static_cast<FXJSE_CLASS_DESCRIPTOR*>(
285 info.Data().As<v8::External>()->Value()); 285 info.Data().As<v8::External>()->Value());
286 v8::String::Utf8Value szPropName(property); 286 v8::String::Utf8Value szPropName(property);
287 CFX_ByteStringC szFxPropName(*szPropName, szPropName.length()); 287 CFX_ByteStringC szFxPropName(*szPropName, szPropName.length());
288 std::unique_ptr<CFXJSE_Value> lpThisValue( 288 std::unique_ptr<CFXJSE_Value> lpThisValue(
289 new CFXJSE_Value(info.GetIsolate())); 289 new CFXJSE_Value(info.GetIsolate()));
290 lpThisValue->ForceSetValue(thisObject); 290 lpThisValue->ForceSetValue(thisObject);
291 291
292 CFXJSE_Value* lpNewValue = new CFXJSE_Value(info.GetIsolate()); 292 std::unique_ptr<CFXJSE_Value> lpNewValue(new CFXJSE_Value(info.GetIsolate()));
293 lpNewValue->ForceSetValue(value); 293 lpNewValue->ForceSetValue(value);
294 DynPropSetterAdapter(lpClass, lpThisValue.get(), szFxPropName, lpNewValue); 294 DynPropSetterAdapter(lpClass, lpThisValue.get(), szFxPropName,
295 lpNewValue.get());
295 info.GetReturnValue().Set(value); 296 info.GetReturnValue().Set(value);
296 } 297 }
297 298
298 void NamedPropertyEnumeratorCallback( 299 void NamedPropertyEnumeratorCallback(
299 const v8::PropertyCallbackInfo<v8::Array>& info) { 300 const v8::PropertyCallbackInfo<v8::Array>& info) {
300 const FXJSE_CLASS_DESCRIPTOR* lpClass = static_cast<FXJSE_CLASS_DESCRIPTOR*>( 301 const FXJSE_CLASS_DESCRIPTOR* lpClass = static_cast<FXJSE_CLASS_DESCRIPTOR*>(
301 info.Data().As<v8::External>()->Value()); 302 info.Data().As<v8::External>()->Value());
302 v8::Isolate* pIsolate = info.GetIsolate(); 303 v8::Isolate* pIsolate = info.GetIsolate();
303 v8::Local<v8::Array> newArray = v8::Array::New(pIsolate, lpClass->propNum); 304 v8::Local<v8::Array> newArray = v8::Array::New(pIsolate, lpClass->propNum);
304 for (int i = 0; i < lpClass->propNum; i++) { 305 for (int i = 0; i < lpClass->propNum; i++) {
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
424 v8::External::New(pIsolate, 425 v8::External::New(pIsolate,
425 const_cast<FXJSE_CLASS_DESCRIPTOR*>(lpClassDefinition)), 426 const_cast<FXJSE_CLASS_DESCRIPTOR*>(lpClassDefinition)),
426 v8::PropertyHandlerFlags::kNonMasking); 427 v8::PropertyHandlerFlags::kNonMasking);
427 hObjectTemplate->SetHandler(configuration); 428 hObjectTemplate->SetHandler(configuration);
428 } 429 }
429 430
430 CFXJSE_Class::CFXJSE_Class(CFXJSE_Context* lpContext) 431 CFXJSE_Class::CFXJSE_Class(CFXJSE_Context* lpContext)
431 : m_lpClassDefinition(nullptr), m_pContext(lpContext) {} 432 : m_lpClassDefinition(nullptr), m_pContext(lpContext) {}
432 433
433 CFXJSE_Class::~CFXJSE_Class() {} 434 CFXJSE_Class::~CFXJSE_Class() {}
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