From 42e47b462ea4c45496e2367e3bfc168ab433600b Mon Sep 17 00:00:00 2001
From: Jorge Canizales <jcanizales@google.com>
Date: Mon, 18 May 2015 23:38:17 -0700
Subject: [PATCH] Copy values before buffering them.
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

So they aren’t mutated before being written later.
---
 src/objective-c/RxLibrary/GRXBufferedPipe.m | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/src/objective-c/RxLibrary/GRXBufferedPipe.m b/src/objective-c/RxLibrary/GRXBufferedPipe.m
index e1295cef8a..3ef470f89f 100644
--- a/src/objective-c/RxLibrary/GRXBufferedPipe.m
+++ b/src/objective-c/RxLibrary/GRXBufferedPipe.m
@@ -84,6 +84,10 @@
   } else {
     // Even if we're paused and with enqueued values, we can't excert back-pressure to our writer.
     // So just buffer the new value.
+    // We need a copy, so that it doesn't mutate before it's written at the other end of the pipe.
+    if ([value respondsToSelector:@selector(copy)]) {
+      value = [value copy];
+    }
     [_queue addObject:value];
   }
 }
-- 
GitLab