diff options
author | Jorge Canizales <jcanizales@google.com> | 2015-05-18 23:38:17 -0700 |
---|---|---|
committer | Jorge Canizales <jcanizales@google.com> | 2015-05-18 23:39:11 -0700 |
commit | 42e47b462ea4c45496e2367e3bfc168ab433600b (patch) | |
tree | 6a026a23abffa816a5d5a89386de6ec96ce5f9a0 | |
parent | 63e4091dbc0902ea0447bb30940f757478abdef7 (diff) |
Copy values before buffering them.
So they aren’t mutated before being written later.
-rw-r--r-- | src/objective-c/RxLibrary/GRXBufferedPipe.m | 4 |
1 files changed, 4 insertions, 0 deletions
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]; } } |