From 90192458f32c424ba88cc84ecfa2992bce20c2af Mon Sep 17 00:00:00 2001 From: Peter Klausler 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 c714a85a336e7..317f0b676bd21 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) {