From 8e44290341b79d518c4f0486db43790fff167239 Mon Sep 17 00:00:00 2001 From: Stinkfist0 Date: Fri, 24 Feb 2017 14:57:29 +0200 Subject: [PATCH] string_arg_filter: make sure the argument type is string --- src/ifcgeom/IfcGeomFilter.h | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/ifcgeom/IfcGeomFilter.h b/src/ifcgeom/IfcGeomFilter.h index 7ffd16719c..52532870b3 100644 --- a/src/ifcgeom/IfcGeomFilter.h +++ b/src/ifcgeom/IfcGeomFilter.h @@ -120,6 +120,7 @@ namespace IfcGeom } }; + /// @note supports only string arguments for now struct string_arg_filter : public wildcard_filter { // Using this for now in order to overcome the fact that different classes have the argument at different indices. @@ -145,7 +146,8 @@ namespace IfcGeom for (arg_map_t::const_iterator it = args.begin(); it != args.end(); ++it) { IfcWrite::IfcWritableEntity dummy(it->first); IfcUtil::IfcBaseClass* base = IfcSchema::SchemaEntity(&dummy); - assert(it->second < base->getArgumentCount() && "Invalid argument index"); + assert(it->second < base->getArgumentType(it->second) == IfcUtil::Argument_STRING && "Argument type not string"); + assert(it->second < base->getArgumentCount() && "Argument index out of bounds"); delete base; } #endif @@ -154,7 +156,8 @@ namespace IfcGeom std::string value(IfcSchema::IfcProduct* prod) const { for (arg_map_t::const_iterator it = args.begin(); it != args.end(); ++it) { - if (prod->is(it->first) && it->second < prod->entity->getArgumentCount()) { + if (prod->is(it->first) && it->second < prod->entity->getArgumentCount() && + prod->getArgumentType(it->second) == IfcUtil::Argument_STRING) { Argument *arg = prod->entity->getArgument(it->second); if (!arg->isNull()) { return *arg;