[flang-commits] [PATCH] D127024: [flang][runtime] Don't crash after surviving internal output overflow
Peter Klausler via Phabricator via flang-commits
flang-commits at lists.llvm.org
Fri Jun 3 16:02:16 PDT 2022
klausler created this revision.
klausler added a reviewer: vdonaldson.
klausler added a project: Flang.
Herald added a subscriber: jdoerfert.
Herald added a project: All.
klausler requested review of this revision.
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.
https://reviews.llvm.org/D127024
Files:
flang/runtime/internal-unit.cpp
Index: flang/runtime/internal-unit.cpp
===================================================================
--- flang/runtime/internal-unit.cpp
+++ flang/runtime/internal-unit.cpp
@@ -41,7 +41,9 @@
if constexpr (DIR == Direction::Output) {
// Clear the remainder of the current record if anything was written
// 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();
}
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D127024.434182.patch
Type: text/x-patch
Size: 627 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/flang-commits/attachments/20220603/bf522fc8/attachment.bin>
More information about the flang-commits
mailing list