Index: /trunk/disassembler.c
===================================================================
--- /trunk/disassembler.c	(revision 937)
+++ /trunk/disassembler.c	(revision 938)
@@ -33,5 +33,5 @@
 	ALLOC_INIT_ZVAL(list);
 	array_init(list);
-	for (b = xc_sandbox_user_function_begin(); b; b = b->pListNext) {
+	for (b = xc_sandbox_user_function_begin(TSRMLS_C); b; b = b->pListNext) {
 		int keysize, keyLength;
 
@@ -69,5 +69,5 @@
 	ALLOC_INIT_ZVAL(list);
 	array_init(list);
-	for (b = xc_sandbox_user_class_begin(); b; b = b->pListNext) {
+	for (b = xc_sandbox_user_class_begin(TSRMLS_C); b; b = b->pListNext) {
 		int keysize, keyLength;
 
Index: /trunk/utils.c
===================================================================
--- /trunk/utils.c	(revision 937)
+++ /trunk/utils.c	(revision 938)
@@ -765,5 +765,5 @@
 #endif
 
-xc_sandbox_t *xc_sandbox_init(xc_sandbox_t *sandbox, ZEND_24(NOTHING, const) char *filename TSRMLS_DC) /* {{{ */
+static xc_sandbox_t *xc_sandbox_init(xc_sandbox_t *sandbox, ZEND_24(NOTHING, const) char *filename TSRMLS_DC) /* {{{ */
 {
 	HashTable *h;
@@ -930,5 +930,5 @@
 }
 /* }}} */
-void xc_sandbox_free(xc_sandbox_t *sandbox, zend_op_array *op_array TSRMLS_DC) /* {{{ */
+static void xc_sandbox_free(xc_sandbox_t *sandbox, zend_op_array *op_array TSRMLS_DC) /* {{{ */
 {
 	XG(sandbox) = NULL;
@@ -998,31 +998,55 @@
 }
 /* }}} */
-const Bucket *xc_sandbox_user_function_begin() /* {{{ */
+zend_op_array *xc_sandbox(xc_sandboxed_func_t sandboxed_func, void *data, ZEND_24(NOTHING, const) char *filename TSRMLS_DC) /* {{{ */
+{
+	xc_sandbox_t sandbox;
+	zend_op_array *op_array = NULL;
+	zend_bool catched = 0;
+
+	memset(&sandbox, 0, sizeof(sandbox));
+	zend_try {
+		xc_sandbox_init(&sandbox, filename TSRMLS_CC);
+		op_array = sandboxed_func(data TSRMLS_CC);
+	} zend_catch {
+		catched = 1;
+	} zend_end_try();
+
+	xc_sandbox_free(&sandbox, op_array TSRMLS_CC);
+	if (catched) {
+		zend_bailout();
+	}
+	return op_array;
+}
+/* {{{ */
+const Bucket *xc_sandbox_user_function_begin(TSRMLS_D) /* {{{ */
 {
 	xc_sandbox_t *sandbox = (xc_sandbox_t *) XG(sandbox);
 	assert(sandbox);
 	return TG(internal_function_tail) ? TG(internal_function_tail)->pListNext : TG(function_table).pListHead;
-} /* {{{ */
-const Bucket *xc_sandbox_user_class_begin() /* {{{ */
+}
+/* {{{ */
+const Bucket *xc_sandbox_user_class_begin(TSRMLS_D) /* {{{ */
 {
 	xc_sandbox_t *sandbox = (xc_sandbox_t *) XG(sandbox);
 	assert(sandbox);
 	return TG(internal_class_tail) ? TG(internal_class_tail)->pListNext : TG(class_table).pListHead;
-} /* {{{ */
+}
+/* {{{ */
 #ifdef XCACHE_ERROR_CACHING
-xc_compilererror_t *xc_sandbox_compilererrors() /* {{{ */
+xc_compilererror_t *xc_sandbox_compilererrors(TSRMLS_D) /* {{{ */
 {
 	xc_sandbox_t *sandbox = (xc_sandbox_t *) XG(sandbox);
 	assert(sandbox);
 	return sandbox->compilererrors;
-} /* }}} */
-zend_uint xc_sandbox_compilererror_cnt() /* {{{ */
+}
+/* }}} */
+zend_uint xc_sandbox_compilererror_cnt(TSRMLS_D) /* {{{ */
 {
 	xc_sandbox_t *sandbox = (xc_sandbox_t *) XG(sandbox);
 	assert(sandbox);
 	return sandbox->compilererror_cnt;
-} /* }}} */
-#endif
-
+}
+/* }}} */
+#endif
 
 int xc_vtrace(const char *fmt, va_list args) /* {{{ */
Index: /trunk/utils.h
===================================================================
--- /trunk/utils.h	(revision 937)
+++ /trunk/utils.h	(revision 938)
@@ -83,10 +83,10 @@
 typedef zend_op_array *(*xc_sandboxed_func_t)(void *data TSRMLS_DC);
 zend_op_array *xc_sandbox(xc_sandboxed_func_t sandboxed_func, void *data, ZEND_24(NOTHING, const) char *filename TSRMLS_DC);
-const Bucket *xc_sandbox_user_function_begin();
-const Bucket *xc_sandbox_user_class_begin();
-zend_uint xc_sandbox_compilererror_cnt();
+const Bucket *xc_sandbox_user_function_begin(TSRMLS_D);
+const Bucket *xc_sandbox_user_class_begin(TSRMLS_D);
+zend_uint xc_sandbox_compilererror_cnt(TSRMLS_D);
 #ifdef XCACHE_ERROR_CACHING
-xc_compilererror_t *xc_sandbox_compilererrors();
-zend_uint xc_sandbox_compilererror_cnt();
+xc_compilererror_t *xc_sandbox_compilererrors(TSRMLS_D);
+zend_uint xc_sandbox_compilererror_cnt(TSRMLS_D);
 #endif
 
Index: /trunk/xcache.c
===================================================================
--- /trunk/xcache.c	(revision 937)
+++ /trunk/xcache.c	(revision 938)
@@ -1810,6 +1810,6 @@
 	/* }}} */
 #ifdef XCACHE_ERROR_CACHING
-	compiler->new_php.compilererrors = xc_sandbox_compilererrors();
-	compiler->new_php.compilererror_cnt = xc_sandbox_compilererror_cnt();
+	compiler->new_php.compilererrors = xc_sandbox_compilererrors(TSRMLS_C);
+	compiler->new_php.compilererror_cnt = xc_sandbox_compilererror_cnt(TSRMLS_C);
 #endif
 #ifndef ZEND_COMPILE_DELAYED_BINDING
