[pure-lang-svn] SF.net SVN: pure-lang: [24] pure/trunk
Status: Beta
Brought to you by:
agraef
From: <ag...@us...> - 2008-05-02 05:31:22
|
Revision: 24 http://pure-lang.svn.sourceforge.net/pure-lang/?rev=24&view=rev Author: agraef Date: 2008-05-01 22:31:22 -0700 (Thu, 01 May 2008) Log Message: ----------- Catch stack overflow in printer. Modified Paths: -------------- pure/trunk/printer.cc pure/trunk/runtime.cc Modified: pure/trunk/printer.cc =================================================================== --- pure/trunk/printer.cc 2008-05-02 05:00:29 UTC (rev 23) +++ pure/trunk/printer.cc 2008-05-02 05:31:22 UTC (rev 24) @@ -606,6 +606,11 @@ ostream& operator << (ostream& os, const pure_expr *x) { + char test; + if (interpreter::stackmax > 0 && + interpreter::stackdir*(&test - interpreter::baseptr) >= + interpreter::stackmax) + throw err("stack overflow in printer"); char buf[64]; assert(x); //os << "{" << x->refc << "}"; Modified: pure/trunk/runtime.cc =================================================================== --- pure/trunk/runtime.cc 2008-05-02 05:00:29 UTC (rev 23) +++ pure/trunk/runtime.cc 2008-05-02 05:31:22 UTC (rev 24) @@ -1040,8 +1040,12 @@ { assert(x); ostringstream os; - os << x; - return pure_string_dup(os.str().c_str()); + try { + os << x; + return pure_string_dup(os.str().c_str()); + } catch (err &e) { + return 0; + } } extern "C" This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |