[flang-commits] [flang] 7463b46 - [flang][runtime] Fix use of empty optional in BOZ input (#120789)

via flang-commits flang-commits at lists.llvm.org
Wed Jan 8 13:12:28 PST 2025


Author: Peter Klausler
Date: 2025-01-08T13:12:25-08:00
New Revision: 7463b46a34efedbc3a72d05721886284e80b5cce

URL: https://github.com/llvm/llvm-project/commit/7463b46a34efedbc3a72d05721886284e80b5cce
DIFF: https://github.com/llvm/llvm-project/commit/7463b46a34efedbc3a72d05721886284e80b5cce.diff

LOG: [flang][runtime] Fix use of empty optional in BOZ input (#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.

Added: 
    

Modified: 
    flang/runtime/edit-input.cpp

Removed: 
    


################################################################################
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