Index: /trunk/optimizer.c
===================================================================
--- /trunk/optimizer.c	(revision 365)
+++ /trunk/optimizer.c	(revision 369)
@@ -460,4 +460,5 @@
 	int i;
 	bbid_t lasttrybbid;
+	bbid_t lastcatchbbid;
 
 	for (i = 0; i < bbs_count(bbs); i ++) {
@@ -482,18 +483,20 @@
 	}
 
-	lasttrybbid = BBID_INVALID;
+	lasttrybbid   = BBID_INVALID;
+	lastcatchbbid = BBID_INVALID;
 	op_array->last_try_catch = 0;
 	for (i = 0; i < bbs_count(bbs); i ++) {
 		bb_t *bb = bbs_get(bbs, i);
 
-		if (lasttrybbid != bb->catch) {
-			if (lasttrybbid != BBID_INVALID) {
+		if (lastcatchbbid != bb->catch) {
+			if (lasttrybbid != BBID_INVALID && lastcatchbbid != BBID_INVALID) {
 				int try_catch_offset = op_array->last_try_catch ++;
 
 				op_array->try_catch_array = erealloc(op_array->try_catch_array, sizeof(zend_try_catch_element) * op_array->last_try_catch);
 				op_array->try_catch_array[try_catch_offset].try_op = bbs_get(bbs, lasttrybbid)->opnum;
-				op_array->try_catch_array[try_catch_offset].catch_op = bbs_get(bbs, bb->id)->opnum;
-			}
-			lasttrybbid = bb->catch;
+				op_array->try_catch_array[try_catch_offset].catch_op = bbs_get(bbs, lastcatchbbid)->opnum;
+			}
+			lasttrybbid   = i;
+			lastcatchbbid = bb->catch;
 		}
 	}
@@ -549,4 +552,5 @@
 	xc_dprint_zend_op_array(op_array, 0 TSRMLS_CC);
 #	endif
+	op_print(0, op_array->opcodes, op_array->opcodes + op_array->last);
 #endif
 	return 0;
