Skip to content

Conversation

@klausler
Copy link
Contributor

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.

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.
@klausler klausler requested a review from vzakhari December 20, 2024 19:30
@llvmbot llvmbot added flang:runtime flang Flang issues not falling into any other category labels Dec 20, 2024
@llvmbot
Copy link
Member

llvmbot commented Dec 20, 2024

@llvm/pr-subscribers-flang-runtime

Author: Peter Klausler (klausler)

Changes

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.


Full diff: https://github.com/llvm/llvm-project/pull/120789.diff

1 Files Affected:

  • (modified) flang/runtime/edit-input.cpp (+1-1)
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) {

Copy link
Contributor

@vzakhari vzakhari left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@klausler klausler merged commit 7463b46 into llvm:main Jan 8, 2025
11 checks passed
@klausler klausler deleted the bug113 branch January 8, 2025 21:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

flang:runtime flang Flang issues not falling into any other category

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants