Skip to content

Commit

Permalink
Fix a bug where toNSInputStream would leak if the stream is closed be…
Browse files Browse the repository at this point in the history
…fore being fully read (#1663)
  • Loading branch information
brianquinlan authored Oct 17, 2024
1 parent 10077a4 commit 6a6079a
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion pkgs/objective_c/lib/src/ns_input_stream.dart
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,12 @@ extension NSInputStreamStreamExtension on Stream<List<int>> {
port.listen((count) {
// -1 indicates that the `NSInputStream` is closed. All other values
// indicate that the `NSInputStream` needs more data.
//
// If [DartInputStreamAdapter.setError_] or
// [DartInputStreamAdapter.setDone] is called then the close message (-1)
// will not be sent when the input stream is closed.
if (count == -1) {
dataSubscription.cancel();
port.close();
} else {
dataSubscription.resume();
}
Expand Down

0 comments on commit 6a6079a

Please sign in to comment.