diff options
author | randomdan <randomdan@localhost> | 2012-04-27 20:13:18 +0000 |
---|---|---|
committer | randomdan <randomdan@localhost> | 2012-04-27 20:13:18 +0000 |
commit | 9416d6dfb329740505d4ea733bda0c65f406ca81 (patch) | |
tree | eea162316d53e96ecf9d4a3830057d44d9e40e49 /project2/cgi | |
parent | Check presenter caches are at least as new as their source scripts (bug17) (diff) | |
download | project2-9416d6dfb329740505d4ea733bda0c65f406ca81.tar.bz2 project2-9416d6dfb329740505d4ea733bda0c65f406ca81.tar.xz project2-9416d6dfb329740505d4ea733bda0c65f406ca81.zip |
Fixed memory leak in HtmlDocument (free doc)
Fix crash when internal transforms and debug document are enabled together (remove debug target transform from presenter)
Diffstat (limited to 'project2/cgi')
-rw-r--r-- | project2/cgi/cgiAppEngine.cpp | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/project2/cgi/cgiAppEngine.cpp b/project2/cgi/cgiAppEngine.cpp index ea50627..566b979 100644 --- a/project2/cgi/cgiAppEngine.cpp +++ b/project2/cgi/cgiAppEngine.cpp @@ -138,26 +138,28 @@ CgiApplicationEngine::process() const } if (TransformSourcePtr ts = currentStage.get<2>()) { TransformSourcePtr final = finalTransformSource(ts); - ScopeObject emptyFinal(boost::bind(&TransformSource::clearTargets, final)); + ScopeObject emptyFinal([final] { final->clearTargets(); }); final->addTarget(new CgiResult(header, IO, rs && rs->root ? rs->root->value("encoding", _env->outputEncoding) : VariableType(_env->outputEncoding)), NULL); BOOST_FOREACH(const PresenterCachePtr & p, rs->caches) { final->addTarget(p, NULL); } - std::fstream * ddd = NULL; + boost::shared_ptr<std::fstream> ddd; + ostreamWrapper * osw = NULL; + ScopeObject removeDdd([ts, &osw] { if (osw) { ts->removeTarget(osw); } }); if (!_env->dumpdatadoc.empty()) { - ddd = new std::fstream(_env->dumpdatadoc.c_str(), std::fstream::trunc | std::fstream::out); + ddd = boost::shared_ptr<std::fstream>(new std::fstream(_env->dumpdatadoc.c_str(), std::fstream::trunc | std::fstream::out)); if (ddd->good()) { - ts->addTarget(new ostreamWrapper(*ddd)); + ts->addTarget(osw = new ostreamWrapper(*ddd)); + } + else { + ddd.reset(); } } ts->doTransforms(); BOOST_FOREACH(const PresenterCachePtr & p, rs->caches) { p->flushCache(); } - if (ddd) { - delete ddd; - } } else { header->render(IO); |