From: mfranz Date: Wed, 10 Oct 2007 19:24:17 +0000 (+0000) Subject: setprop(): report error on writing to unwritable property X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=e3c2cf3abc3899f7d4356934dfb13c3fe099edab;p=flightgear.git setprop(): report error on writing to unwritable property --- diff --git a/src/Scripting/NasalSys.cxx b/src/Scripting/NasalSys.cxx index c2d6d4295..92ec647df 100644 --- a/src/Scripting/NasalSys.cxx +++ b/src/Scripting/NasalSys.cxx @@ -222,17 +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)) props->setStringValue(buf, naStr_data(val)); + if(naIsString(val)) ret = props->setStringValue(buf, naStr_data(val)); else { naRef n = naNumValue(val); if(naIsNil(n)) naRuntimeError(c, "setprop() value is not string or number"); - props->setDoubleValue(buf, n.num); + ret = props->setDoubleValue(buf, n.num); } } catch (const string& err) { naRuntimeError(c, (char *)err.c_str()); } + if(!ret) naRuntimeError(c, "setprop(): property is not writable"); return naNil(); #undef BUFLEN }