forked from OSchip/llvm-project
[flang][runtime] Don't crash after surviving internal output overflow
After the program has survived its attempt to overflow the output buffer with an internal WRITE using ERR=, IOSTAT=, &/or IOMSG=, don't crash by accidentally blank-filling the next record that usually doesn't exist. Differential Revision: https://reviews.llvm.org/D127024
This commit is contained in:
parent
ea1a69d66d
commit
ea5b205bb8
|
@ -41,7 +41,9 @@ template <Direction DIR> void InternalDescriptorUnit<DIR>::EndIoStatement() {
|
||||||
if constexpr (DIR == Direction::Output) {
|
if constexpr (DIR == Direction::Output) {
|
||||||
// Clear the remainder of the current record if anything was written
|
// Clear the remainder of the current record if anything was written
|
||||||
// to it, or if it is the only record.
|
// to it, or if it is the only record.
|
||||||
if (endfileRecordNumber.value_or(-1) == 2 || furthestPositionInRecord > 0) {
|
auto end{endfileRecordNumber.value_or(0)};
|
||||||
|
if (currentRecordNumber < end &&
|
||||||
|
(end == 2 || furthestPositionInRecord > 0)) {
|
||||||
BlankFillOutputRecord();
|
BlankFillOutputRecord();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue