mzsk / tiny-js

Automatically exported from code.google.com/p/tiny-js
0 stars 0 forks source link

Crash: calling execute() within a native function within a javascript function within execute() :P #5

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
*What steps will reproduce the problem?*
1. Add a native function "exec(s)" to a CTinyJS object, containing the 
following code:
try {
  cjs->execute( v->getParameter("s")->getString().c_str() );
} catch (CScriptException *ex) {
  v->getReturnVar()->setString( ex->text.c_str() );
}

2. Set up the concentric execution via a javascript function:
cjs->exec( "function e(s) { return exec(s); } ");

3. Test that the function ordinarily doesn't cause any problems
cjs->exec( "e(\"var f = 3\"); ");
// Doesn't cause any problems, f is a javascript integer containing the value 3

4. Test that a syntax error causes a hard crash
cjs->exec( "var f = e(\"syntaxerror\"); ");

*What is the expected output? What do you see instead?*
Expected: f is a javascript string containing some error message about 
"syntaxerror"
Result: Crash in CTinyJS::statement 

*What version of the product are you using? On what operating system?*
TinyJS trunk 0.23, Visual Studio 2010, Windows 7 (slightly old version of 
TinyJS, i can attempt to reproduce with a newer version)

*Please provide any additional information below.*
I have TinyJS hooked up to a command-line that cjs->execute()'s everything it's 
given. I have that hooked up to a chat room. I was trying to make it so that 
the bot could execute() instead of eval() commands that it was given, with all 
logic JS-side

Apologies if i've made a mistake, left something out, or if this has been fixed 
already in a newer revision..

Original issue reported on code.google.com by toaster...@gmail.com on 25 Oct 2011 at 7:58