Index: /branches/1.2/xcache.c
===================================================================
--- /branches/1.2/xcache.c	(revision 436)
+++ /branches/1.2/xcache.c	(revision 437)
@@ -1464,5 +1464,5 @@
 	int i;
 
-	if (XG(internal_function_table).nTableSize == 0) {
+	if (!XG(internal_table_copied)) {
 		zend_function tmp_func;
 		xc_cest_t tmp_cest;
@@ -1476,4 +1476,6 @@
 		zend_hash_copy(&XG(internal_function_table), CG(function_table), (copy_ctor_func_t) function_add_ref, &tmp_func, sizeof(tmp_func));
 		zend_hash_copy(&XG(internal_class_table), CG(class_table), (copy_ctor_func_t) xc_zend_class_add_ref, &tmp_cest, sizeof(tmp_cest));
+
+		XG(internal_table_copied) = 1;
 	}
 	if (xc_php_hcache.size && !XG(php_holds)) {
@@ -1525,5 +1527,4 @@
 	zend_hash_init_ex(&xcache_globals->internal_function_table, 1, NULL, NULL, 1, 0);
 	zend_hash_init_ex(&xcache_globals->internal_class_table,    1, NULL, NULL, 1, 0);
-
 }
 /* }}} */
@@ -1554,6 +1555,8 @@
 	}
 
-	zend_hash_destroy(&xcache_globals->internal_function_table);
-	zend_hash_destroy(&xcache_globals->internal_class_table);
+	if (XG(internal_table_copied)) {
+		zend_hash_destroy(&xcache_globals->internal_function_table);
+		zend_hash_destroy(&xcache_globals->internal_class_table);
+	}
 }
 /* }}} */
Index: /branches/1.2/xcache_globals.h
===================================================================
--- /branches/1.2/xcache_globals.h	(revision 436)
+++ /branches/1.2/xcache_globals.h	(revision 437)
@@ -20,4 +20,5 @@
 	HashTable internal_function_table;
 	HashTable internal_class_table;
+	zend_bool internal_table_copied;
 ZEND_END_MODULE_GLOBALS(xcache)
 
