aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorlloyd <[email protected]>2008-10-08 19:24:43 +0000
committerlloyd <[email protected]>2008-10-08 19:24:43 +0000
commit3b14bc3a42a03c6d9fb2a4483574591f747a3d90 (patch)
tree0d8db002e7857a135105f3424e39612a0abc6167 /src
parenta404bec44f5c702b0a8a469c8d458856982b293e (diff)
Avoid a memory leak if lookup of a component algorithm of Lion cannot be
found by using auto_ptr
Diffstat (limited to 'src')
-rw-r--r--src/core/libstate/def_alg.cpp11
1 files changed, 9 insertions, 2 deletions
diff --git a/src/core/libstate/def_alg.cpp b/src/core/libstate/def_alg.cpp
index 7199b06bd..c637262ee 100644
--- a/src/core/libstate/def_alg.cpp
+++ b/src/core/libstate/def_alg.cpp
@@ -399,8 +399,15 @@ Default_Engine::find_block_cipher(const std::string& algo_spec) const
if(name.size() != 4)
throw Invalid_Algorithm_Name(algo_spec);
- return new Lion(get_hash(name[1]), get_stream_cipher(name[2]),
- to_u32bit(name[3]));
+ std::auto_ptr<HashFunction> hash(get_hash(name[1]));
+ if(!hash.get())
+ throw Algorithm_Not_Found(name[1]);
+
+ std::auto_ptr<StreamCipher> sc(get_stream_cipher(name[2]));
+ if(!sc.get())
+ throw Algorithm_Not_Found(name[2]);
+
+ return new Lion(hash.release(), sc.release(), to_u32bit(name[3]));
}
#endif