Index: gst/gstpad.c
===================================================================
RCS file: /cvs/gstreamer/gstreamer/gst/gstpad.c,v
retrieving revision 1.511
diff -u -p -r1.511 gstpad.c
--- gst/gstpad.c	4 May 2006 16:34:20 -0000	1.511
+++ gst/gstpad.c	5 May 2006 16:12:34 -0000
@@ -883,7 +883,10 @@ gst_pad_set_blocked_async (GstPad * pad,
 
   g_return_val_if_fail (GST_IS_PAD (pad), FALSE);
 
-  if (GST_IS_GHOST_PAD (pad)) {
+  while (GST_IS_GHOST_PAD (pad)) {
+    if (was_ghost)
+      gst_object_unref (pad);
+
     pad = gst_ghost_pad_get_target (GST_GHOST_PAD (pad));
     if (!pad) {
       return FALSE;
Index: gst/gstutils.c
===================================================================
RCS file: /cvs/gstreamer/gstreamer/gst/gstutils.c,v
retrieving revision 1.140
diff -u -p -r1.140 gstutils.c
--- gst/gstutils.c	4 May 2006 15:20:14 -0000	1.140
+++ gst/gstutils.c	5 May 2006 16:12:34 -0000
@@ -2754,7 +2754,9 @@ gst_pad_add_data_probe (GstPad * pad, GC
   g_return_val_if_fail (GST_IS_PAD (pad), 0);
   g_return_val_if_fail (handler != NULL, 0);
 
-  if (GST_IS_GHOST_PAD (pad)) {
+  while (GST_IS_GHOST_PAD (pad)) {
+    if (was_ghost)
+      gst_object_unref (pad);
     pad = gst_ghost_pad_get_target (GST_GHOST_PAD (pad));
     if (!pad) {
       return 0;
@@ -2798,7 +2800,9 @@ gst_pad_add_event_probe (GstPad * pad, G
   g_return_val_if_fail (GST_IS_PAD (pad), 0);
   g_return_val_if_fail (handler != NULL, 0);
 
-  if (GST_IS_GHOST_PAD (pad)) {
+  while (GST_IS_GHOST_PAD (pad)) {
+    if (was_ghost)
+      gst_object_unref (pad);
     pad = gst_ghost_pad_get_target (GST_GHOST_PAD (pad));
     if (!pad) {
       return 0;
@@ -2840,7 +2844,9 @@ gst_pad_add_buffer_probe (GstPad * pad, 
   g_return_val_if_fail (GST_IS_PAD (pad), 0);
   g_return_val_if_fail (handler != NULL, 0);
 
-  if (GST_IS_GHOST_PAD (pad)) {
+  while (GST_IS_GHOST_PAD (pad)) {
+    if (was_ghost)
+      gst_object_unref (pad);
     pad = gst_ghost_pad_get_target (GST_GHOST_PAD (pad));
     if (!pad) {
       return 0;
@@ -2877,7 +2883,9 @@ gst_pad_remove_data_probe (GstPad * pad,
   g_return_if_fail (GST_IS_PAD (pad));
   g_return_if_fail (handler_id > 0);
 
-  if (GST_IS_GHOST_PAD (pad)) {
+  while (GST_IS_GHOST_PAD (pad)) {
+    if (was_ghost)
+      gst_object_unref (pad);
     pad = gst_ghost_pad_get_target (GST_GHOST_PAD (pad));
     if (!pad) {
       return;
@@ -2915,7 +2923,9 @@ gst_pad_remove_event_probe (GstPad * pad
   g_return_if_fail (GST_IS_PAD (pad));
   g_return_if_fail (handler_id > 0);
 
-  if (GST_IS_GHOST_PAD (pad)) {
+  while (GST_IS_GHOST_PAD (pad)) {
+    if (was_ghost)
+      gst_object_unref (pad);
     pad = gst_ghost_pad_get_target (GST_GHOST_PAD (pad));
     if (!pad) {
       return;
@@ -2950,7 +2960,9 @@ gst_pad_remove_buffer_probe (GstPad * pa
   g_return_if_fail (GST_IS_PAD (pad));
   g_return_if_fail (handler_id > 0);
 
-  if (GST_IS_GHOST_PAD (pad)) {
+  while (GST_IS_GHOST_PAD (pad)) {
+    if (was_ghost)
+      gst_object_unref (pad);
     pad = gst_ghost_pad_get_target (GST_GHOST_PAD (pad));
     if (!pad) {
       return;
