diff options
| author | Arseny Kapoulkine <arseny.kapoulkine@gmail.com> | 2017-01-30 21:45:01 -0800 | 
|---|---|---|
| committer | Arseny Kapoulkine <arseny.kapoulkine@gmail.com> | 2017-01-30 21:58:53 -0800 | 
| commit | ac150d504e0e1fa54eb042325c87f08740f1d4f6 (patch) | |
| tree | 6a95190382c43348e9efdf636d459c26b906821a /src | |
| parent | 02cee98492233f4ae91f025fc38f9df8b4bc0efe (diff) | |
XPath: Throw std::bad_alloc if we got an out-of-memory error
This allows us to gradually convert exception handling of out-of-memory
during evaluation to a non-throwing approach without changing the
observable behavior.
Diffstat (limited to 'src')
| -rw-r--r-- | src/pugixml.cpp | 20 | 
1 files changed, 20 insertions, 0 deletions
| diff --git a/src/pugixml.cpp b/src/pugixml.cpp index c6fee40..2e25551 100644 --- a/src/pugixml.cpp +++ b/src/pugixml.cpp @@ -11870,6 +11870,10 @@ PUGI__NS_BEGIN  		xpath_string r = impl->root->eval_string(c, sd.stack); +	#ifndef PUGIXML_NO_EXCEPTIONS +		if (sd.error) throw std::bad_alloc(); +	#endif +  		return sd.error ? xpath_string() : r;  	} @@ -12510,6 +12514,10 @@ namespace pugi  		bool r = static_cast<impl::xpath_query_impl*>(_impl)->root->eval_boolean(c, sd.stack); +	#ifndef PUGIXML_NO_EXCEPTIONS +		if (sd.error) throw std::bad_alloc(); +	#endif +  		return sd.error ? false : r;  	} @@ -12526,6 +12534,10 @@ namespace pugi  		double r = static_cast<impl::xpath_query_impl*>(_impl)->root->eval_number(c, sd.stack); +	#ifndef PUGIXML_NO_EXCEPTIONS +		if (sd.error) throw std::bad_alloc(); +	#endif +  		return sd.error ? impl::gen_nan() : r;  	} @@ -12574,6 +12586,10 @@ namespace pugi  		impl::xpath_node_set_raw r = root->eval_node_set(c, sd.stack, impl::nodeset_eval_all); +	#ifndef PUGIXML_NO_EXCEPTIONS +		if (sd.error) throw std::bad_alloc(); +	#endif +  		return sd.error ? xpath_node_set() : xpath_node_set(r.begin(), r.end(), r.type());  	} @@ -12591,6 +12607,10 @@ namespace pugi  		impl::xpath_node_set_raw r = root->eval_node_set(c, sd.stack, impl::nodeset_eval_first); +	#ifndef PUGIXML_NO_EXCEPTIONS +		if (sd.error) throw std::bad_alloc(); +	#endif +  		return sd.error ? xpath_node() : r.first();  	} | 
