--- amf.c.orig	2010-01-05 04:23:23.000000000 +0100
+++ amf.c	2010-01-05 04:29:37.000000000 +0100
@@ -1185,7 +1185,6 @@
 		int resultType = AMFC_TYPEDOBJECT;
 		int resultValueLength = 0;
 		zval** resultValue = struc;
-		int deallocResult = (*struc)->refcount;
 
 		resultType = amf_perform_serialize_callback(struc, &className,&classNameLen,&resultValue,var_hash TSRMLS_CC);
 		
@@ -2670,7 +2669,7 @@
 		}
 		else
 		{
-			newval->refcount--;
+			Z_DELREF_P(newval);
 		}
 		*rval = newval;
 	}
