@@ -252,6 +252,7 @@ void FUNCTION_NAME(File_ReadInto)(Dart_NativeArguments args) {
252
252
}
253
253
254
254
int64_t bytes_read = file->Read (reinterpret_cast <void *>(buffer), length);
255
+ OSError os_error; // capture error if any
255
256
if (is_byte_data) {
256
257
ThrowIfError (Dart_TypedDataReleaseData (buffer_obj));
257
258
}
@@ -261,7 +262,7 @@ void FUNCTION_NAME(File_ReadInto)(Dart_NativeArguments args) {
261
262
}
262
263
Dart_SetIntegerReturnValue (args, bytes_read);
263
264
} else {
264
- Dart_SetReturnValue (args, DartUtils::NewDartOSError ());
265
+ Dart_SetReturnValue (args, DartUtils::NewDartOSError (&os_error ));
265
266
}
266
267
}
267
268
@@ -1145,8 +1146,9 @@ CObject* File::ReadRequest(const CObjectArray& request) {
1145
1146
uint8_t * data = io_buffer->value .as_external_typed_data .data ;
1146
1147
const int64_t bytes_read = file->Read (data, length);
1147
1148
if (bytes_read < 0 ) {
1149
+ CObject* error = CObject::NewOSError ();
1148
1150
CObject::FreeIOBufferData (io_buffer);
1149
- return CObject::NewOSError () ;
1151
+ return error ;
1150
1152
}
1151
1153
1152
1154
// Possibly shrink the used malloc() storage if the actual number of bytes is
@@ -1180,8 +1182,9 @@ CObject* File::ReadIntoRequest(const CObjectArray& request) {
1180
1182
uint8_t * data = io_buffer->value .as_external_typed_data .data ;
1181
1183
const int64_t bytes_read = file->Read (data, length);
1182
1184
if (bytes_read < 0 ) {
1185
+ CObject* error = CObject::NewOSError ();
1183
1186
CObject::FreeIOBufferData (io_buffer);
1184
- return CObject::NewOSError () ;
1187
+ return error ;
1185
1188
}
1186
1189
1187
1190
// Possibly shrink the used malloc() storage if the actual number of bytes is
0 commit comments