Chapter 18, Custom Publisher & Ownership

When creating a custom publisher, you also create a custom subscription.
In the book ShareReplay example, the ShareReplay subscription owns a reference to the subscriber, but I don’t see that it holds on to the upstream publisher. On the other hand, the ShareReplay publisher, does own the upstream publisher.

Unless I’m mistaken the ShareReplay publisher will deinit after the function that created it goes out of the stack, unless it is hold in a class variable. Is this the intended behavior?