From 8418303ce25183f479cda79de08ac0a0e1b6f77d Mon Sep 17 00:00:00 2001 From: Dave Hickin Date: Thu, 9 Jul 2015 13:21:45 +0100 Subject: [PATCH] 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 --- src/factory/PVStructure.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/factory/PVStructure.cpp b/src/factory/PVStructure.cpp index 3977151..5d61056 100644 --- a/src/factory/PVStructure.cpp +++ b/src/factory/PVStructure.cpp @@ -170,7 +170,7 @@ PVField* PVStructure::GetAsImpl(const char *name) const if(*sep) { // this is not the requested leaf parent = dynamic_cast(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 '.'