File tree Expand file tree Collapse file tree 2 files changed +18
-0
lines changed Expand file tree Collapse file tree 2 files changed +18
-0
lines changed Original file line number Diff line number Diff line change @@ -953,6 +953,11 @@ void FUNCTION_NAME(Socket_GetFD)(Dart_NativeArguments args) {
953
953
void FUNCTION_NAME (Socket_GetType)(Dart_NativeArguments args) {
954
954
Socket* socket =
955
955
Socket::GetSocketIdNativeField (Dart_GetNativeArgument (args, 0 ));
956
+ if (socket->fd () < 0 ) {
957
+ OSError os_error (-1 , " Socket is closed." , OSError::kUnknown );
958
+ Dart_SetReturnValue (args, DartUtils::NewDartOSError (&os_error));
959
+ return ;
960
+ }
956
961
OSError os_error;
957
962
intptr_t type = SocketBase::GetType (socket->fd ());
958
963
if (type >= 0 ) {
Original file line number Diff line number Diff line change
1
+ // Copyright (c) 2025, the Dart project authors. Please see the AUTHORS file
2
+ // for details. All rights reserved. Use of this source code is governed by a
3
+ // BSD-style license that can be found in the LICENSE file.
4
+ //
5
+ // Tests that asking closed stdin for its type doesn't crash.
6
+ // The crash was reported on https://github.com/dart-lang/sdk/issues/61571.
7
+
8
+ import 'dart:io' ;
9
+
10
+ void main () async {
11
+ stdin.listen ((_) {}).cancel ();
12
+ stdin.hasTerminal;
13
+ }
You can’t perform that action at this time.
0 commit comments