summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorportix <portix@gmx.net>2014-02-24 01:42:51 +0100
committerportix <portix@gmx.net>2014-02-24 01:42:51 +0100
commit4d384d1caea1989aa816990cb6e68b607f18c407 (patch)
tree69bdbdd2998ce181d9dec1e2db96f5a1866dc731
parent97a2552ca3818dc84856048f6b9a5fea9b8bd158 (diff)
downloaddwb-4d384d1caea1989aa816990cb6e68b607f18c407.zip
Remove all handles if an assertion is thrown
-rw-r--r--src/scripts.c11
1 files changed, 6 insertions, 5 deletions
diff --git a/src/scripts.c b/src/scripts.c
index 2287deee..51212ba8 100644
--- a/src/scripts.c
+++ b/src/scripts.c
@@ -7305,10 +7305,11 @@ init_script(const char *path, const char *script, gboolean is_archive, const cha
if (js_check_syntax(s_global_context, script, path, 2))
{
/**
- * Prints an assertion message and returns, if called in the global
- * context of a script it stops the execution of the script. Note that
- * \__assert\__ is not actually a function but a macro, a ; is mandatory
- * at the end of an \__assert\__ statement.
+ * Prints an assertion message and removes all handles owned by the
+ * script. If called in the global context of a script it stops the
+ * execution of the script. Note that \__assert\__ is not actually a
+ * function but a macro, a ; is mandatory at the end of an \__assert\__
+ * statement.
*
* @name __assert__
* @function
@@ -7328,7 +7329,7 @@ init_script(const char *path, const char *script, gboolean is_archive, const cha
*
* */
prepared = init_macro(script, "assert",
- "if(!(\\1)){try{throw new Error();}catch(e){io.debug('Assertion in %s:'+(e.line)+' failed: \\1');};return;}",
+ "if(!(\\1)){try{script.removeHandles();throw new Error();}catch(e){io.debug('Assertion in %s:'+(e.line)+' failed: \\1');};return;}",
path);
if (prepared != NULL) {
debug = g_strdup_printf(template, path, prepared);