From b2759d018b633ec9f0ca6f9e79d9e21ac24d0eba Mon Sep 17 00:00:00 2001 From: James Turner Date: Wed, 2 Oct 2013 22:08:17 +0100 Subject: [PATCH] Fix a crash with GPS dialog. If an invalid filter type is supplied, don't run the queries. This showed up with GPS dialog, since the PUI combo box defaults to no entry selected, not the first entry. --- src/Scripting/NasalPositioned_cppbind.cxx | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/Scripting/NasalPositioned_cppbind.cxx b/src/Scripting/NasalPositioned_cppbind.cxx index d0fe0b942..eb9a14158 100644 --- a/src/Scripting/NasalPositioned_cppbind.cxx +++ b/src/Scripting/NasalPositioned_cppbind.cxx @@ -395,9 +395,13 @@ static naRef f_findWithinRange(nasal::CallContext ctx) { SGGeod pos = getPosition(ctx); double range_nm = ctx.requireArg(0); - - FGPositioned::TypeFilter filter(FGPositioned::typeFromName(ctx.getArg(1))); + + FGPositioned::Type ty = FGPositioned::typeFromName(ctx.getArg(1)); + if (ty == FGPositioned::INVALID) + naRuntimeError(ctx.c, "invalid filter type specification"); + FGPositioned::TypeFilter filter(ty); + FGPositionedList items = FGPositioned::findWithinRange(pos, range_nm, &filter); FGPositioned::sortByRange(items, pos); return ctx.to_nasal(items);