From 40fd20d5d465e0f19b0ce6061410b2399b97ce41 Mon Sep 17 00:00:00 2001 From: mfranz Date: Thu, 11 Oct 2007 07:58:56 +0000 Subject: [PATCH] setprop(): make sure return value is always set --- src/Scripting/NasalSys.cxx | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Scripting/NasalSys.cxx b/src/Scripting/NasalSys.cxx index 16f910ce0..7811895b2 100644 --- a/src/Scripting/NasalSys.cxx +++ b/src/Scripting/NasalSys.cxx @@ -222,19 +222,19 @@ static naRef f_setprop(naContext c, naRef me, int argc, naRef* args) SGPropertyNode* props = globals->get_props(); naRef val = args[argc-1]; - bool ret; try { - if(naIsString(val)) ret = props->setStringValue(buf, naStr_data(val)); + bool r; + if(naIsString(val)) r = props->setStringValue(buf, naStr_data(val)); else { naRef n = naNumValue(val); if(naIsNil(n)) naRuntimeError(c, "setprop() value is not string or number"); - ret = props->setDoubleValue(buf, n.num); + r = props->setDoubleValue(buf, n.num); } + if(!r) naRuntimeError(c, "setprop(): property is not writable"); } catch (const string& err) { naRuntimeError(c, (char *)err.c_str()); } - if(!ret) naRuntimeError(c, "setprop(): property is not writable"); return naNil(); #undef BUFLEN } -- 2.39.5