[flang-commits] [flang] [flang][runtime] Fix use of empty optional in BOZ input (PR #120789)
Peter Klausler via flang-commits
flang-commits at lists.llvm.org
Fri Dec 20 11:30:13 PST 2024
https://github.com/klausler created https://github.com/llvm/llvm-project/pull/120789
Slava reported a valgrind result showing the use of uninitialized data due to an unconditional dereference of an optional in BOZ formatted input editing; fix.
>From 90192458f32c424ba88cc84ecfa2992bce20c2af Mon Sep 17 00:00:00 2001
From: Peter Klausler <pklausler at nvidia.com>
Date: Fri, 20 Dec 2024 11:27:39 -0800
Subject: [PATCH] [flang][runtime] Fix use of empty optional in BOZ input
Slava reported a valgrind result showing the use of uninitialized
data due to an unconditional dereference of an optional in BOZ
formatted input editing; fix.
---
flang/runtime/edit-input.cpp | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/flang/runtime/edit-input.cpp b/flang/runtime/edit-input.cpp
index c714a85a336e72..317f0b676bd21b 100644
--- a/flang/runtime/edit-input.cpp
+++ b/flang/runtime/edit-input.cpp
@@ -130,7 +130,7 @@ static RT_API_ATTRS bool EditBOZInput(
shift = shift - 8; // misaligned octal
}
while (digits > 0) {
- char32_t ch{*io.NextInField(remaining, edit)};
+ char32_t ch{io.NextInField(remaining, edit).value_or(' ')};
int digit{0};
if (ch == ' ' || ch == '\t') {
if (edit.modes.editingFlags & blankZero) {
More information about the flang-commits
mailing list