Fix bug in new PVStructure::getAs function

Fix seg fault when getAs is called with a string of the form x.y (or
x_1. ... x_n.y) where x or (x1. ... .x_i) is not a structure field.

Signed-off-by: Dave Hickin <david.hickin@diamond.ac.uk>
This commit is contained in:
Dave Hickin
2015-07-09 13:21:45 +01:00
parent 40952df965
commit 8418303ce2

View File

@@ -170,7 +170,7 @@ PVField* PVStructure::GetAsImpl(const char *name) const
if(*sep) {
// this is not the requested leaf
parent = dynamic_cast<PVStructure*>(child);
if(!child)
if(!parent)
throw std::runtime_error("mid-field is not a PVStructure"); //TODO: which sub field?
child = NULL;
name = sep+1; // skip past '.'