Index: /trunk/xcache.c
===================================================================
--- /trunk/xcache.c	(revision 321)
+++ /trunk/xcache.c	(revision 322)
@@ -1316,6 +1316,8 @@
 	}
 
-	xc_free_php(&php TSRMLS_CC);
-	xc_sandbox_free(&sandbox, 0 TSRMLS_CC);
+	if (newlycompiled) {
+		xc_free_php(&php TSRMLS_CC);
+		xc_sandbox_free(&sandbox, 0 TSRMLS_CC);
+	}
 
 	if (stored_xce) {
@@ -1334,6 +1336,8 @@
 
 err_aftersandbox:
-	xc_free_php(&php TSRMLS_CC);
-	xc_sandbox_free(&sandbox, 0 TSRMLS_CC);
+	if (newlycompiled) {
+		xc_free_php(&php TSRMLS_CC);
+		xc_sandbox_free(&sandbox, 0 TSRMLS_CC);
+	}
 
 	if (catched) {
