Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Issue 10173031: Don`t use references to JsEngine to avoid use-after-free errors,switch to shared_ptr instead (Closed)

Created:
April 18, 2013, 4:15 p.m. by Wladimir Palant
Modified:
April 19, 2013, 6:06 a.m.
Reviewers:
Felix Dahlke
Visibility:
Public.

Description

Don`t use references to JsEngine to avoid use-after-free errors, switch to shared_ptr instead

Patch Set 1 #

Total comments: 3
Unified diffs Side-by-side diffs Delta from patch set Stats (+360 lines, -339 lines) Patch
M include/AdblockPlus/FilterEngine.h View 2 chunks +3 lines, -3 lines 0 comments Download
M include/AdblockPlus/JsEngine.h View 2 chunks +7 lines, -4 lines 0 comments Download
M include/AdblockPlus/JsValue.h View 2 chunks +8 lines, -8 lines 0 comments Download
M shell/src/GcCommand.h View 1 chunk +2 lines, -2 lines 0 comments Download
M shell/src/GcCommand.cpp View 1 chunk +2 lines, -2 lines 0 comments Download
M shell/src/Main.cpp View 1 chunk +1 line, -1 line 0 comments Download
M src/AppInfoJsObject.h View 1 chunk +2 lines, -1 line 0 comments Download
M src/AppInfoJsObject.cpp View 1 chunk +1 line, -1 line 0 comments Download
M src/ConsoleJsObject.h View 1 chunk +2 lines, -1 line 0 comments Download
M src/ConsoleJsObject.cpp View 1 chunk +6 lines, -7 lines 0 comments Download
M src/FileSystemJsObject.h View 1 chunk +2 lines, -1 line 0 comments Download
M src/FileSystemJsObject.cpp View 7 chunks +29 lines, -30 lines 0 comments Download
M src/FilterEngine.cpp View 7 chunks +22 lines, -22 lines 0 comments Download
M src/GlobalJsObject.h View 1 chunk +2 lines, -1 line 0 comments Download
M src/GlobalJsObject.cpp View 2 chunks +7 lines, -8 lines 0 comments Download
M src/JsEngine.cpp View 3 chunks +42 lines, -25 lines 3 comments Download
M src/JsValue.cpp View 2 chunks +4 lines, -4 lines 0 comments Download
M src/WebRequestJsObject.h View 1 chunk +2 lines, -1 line 0 comments Download
M src/WebRequestJsObject.cpp View 2 chunks +9 lines, -10 lines 0 comments Download
M test/AppInfoJsObject.cpp View 1 chunk +5 lines, -5 lines 0 comments Download
M test/ConsoleJsObject.cpp View 1 chunk +8 lines, -8 lines 0 comments Download
M test/FileSystemJsObject.cpp View 1 chunk +59 lines, -59 lines 0 comments Download
M test/FilterEngineStubs.cpp View 5 chunks +14 lines, -14 lines 0 comments Download
M test/GlobalJsObject.cpp View 1 chunk +16 lines, -16 lines 0 comments Download
M test/JsEngine.cpp View 1 chunk +38 lines, -38 lines 0 comments Download
M test/JsValue.cpp View 7 chunks +22 lines, -22 lines 0 comments Download
M test/WebRequest.cpp View 1 chunk +45 lines, -45 lines 0 comments Download

Messages

Total messages: 4
Wladimir Palant
April 18, 2013, 4:16 p.m. (2013-04-18 16:16:16 UTC) #1
Felix Dahlke
http://codereview.adblockplus.org/10173031/diff/1/src/JsEngine.cpp File src/JsEngine.cpp (right): http://codereview.adblockplus.org/10173031/diff/1/src/JsEngine.cpp#newcode54 src/JsEngine.cpp:54: AdblockPlus::JsEnginePtr AdblockPlus::JsEngine::New(const AppInfo& appInfo) I don't think we should ...
April 18, 2013, 6:42 p.m. (2013-04-18 18:42:16 UTC) #2
Wladimir Palant
http://codereview.adblockplus.org/10173031/diff/1/src/JsEngine.cpp File src/JsEngine.cpp (right): http://codereview.adblockplus.org/10173031/diff/1/src/JsEngine.cpp#newcode54 src/JsEngine.cpp:54: AdblockPlus::JsEnginePtr AdblockPlus::JsEngine::New(const AppInfo& appInfo) On 2013/04/18 18:42:16, Felix H. ...
April 18, 2013, 8:24 p.m. (2013-04-18 20:24:28 UTC) #3
Felix Dahlke
April 19, 2013, 2:33 a.m. (2013-04-19 02:33:29 UTC) #4
On 2013/04/18 20:24:28, Wladimir Palant wrote:
> http://codereview.adblockplus.org/10173031/diff/1/src/JsEngine.cpp
> File src/JsEngine.cpp (right):
> 
> http://codereview.adblockplus.org/10173031/diff/1/src/JsEngine.cpp#newcode54
> src/JsEngine.cpp:54: AdblockPlus::JsEnginePtr AdblockPlus::JsEngine::New(const
> AppInfo& appInfo)
> On 2013/04/18 18:42:16, Felix H. Dahlke wrote:
> > I don't think we should have this. "JsEnginePtr x(new JsEngine(...))" is
> > actually shorter than "JsEnginePtr x(JsEngine::New(...))", and it's
idiomatic
> > too.
> 
> We need to have the object in a shared_ptr before we can use it properly -
> shared_from_this() will not work in a constructor and we won't be able to pass
> anything to context setup functions. Hence the separation between object
> constructor and initialization.

Hm, I see. Unfortunate but I guess it can't be helped...

LGTM

Powered by Google App Engine
This is Rietveld