mirror of
https://github.com/opencv/opencv.git
synced 2025-01-18 14:13:15 +08:00
Fixed a bug in FLANN resulting in uninitialized accesses.
This is fixed upstream in mariusmuja/flann@b615f26, but that fix would break binary compatibility, so I had to make a different one. Since the bug isn't quite obvious, here's an explanation. In the const version of any::cast, if policy is a small_any_policy, its get_value returns its input argument. So r becomes a pointer to obj, and the return value is a reference to a local variable, which is invalidated when the function exits.
This commit is contained in:
parent
e7f83619c5
commit
a9975b144a
@ -255,8 +255,7 @@ public:
|
|||||||
const T& cast() const
|
const T& cast() const
|
||||||
{
|
{
|
||||||
if (policy->type() != typeid(T)) throw anyimpl::bad_any_cast();
|
if (policy->type() != typeid(T)) throw anyimpl::bad_any_cast();
|
||||||
void* obj = const_cast<void*>(object);
|
T* r = reinterpret_cast<T*>(policy->get_value(const_cast<void **>(&object)));
|
||||||
T* r = reinterpret_cast<T*>(policy->get_value(&obj));
|
|
||||||
return *r;
|
return *r;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user