[PATCH] D99296: [flang] Fix runtime crash on TRIM('')

Peter Klausler via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Mar 24 13:37:42 PDT 2021


klausler created this revision.
klausler added a reviewer: PeteSteinfeld.
klausler added a project: Flang.
Herald added a subscriber: jdoerfert.
klausler requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

The implementation of CFI_establish() incorrectly rejects an
element length of zero, causing a crash when a runtime intrinsic
function tries to return an empty CHARACTER value.  Fix.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D99296

Files:
  flang/runtime/ISO_Fortran_binding.cpp


Index: flang/runtime/ISO_Fortran_binding.cpp
===================================================================
--- flang/runtime/ISO_Fortran_binding.cpp
+++ flang/runtime/ISO_Fortran_binding.cpp
@@ -237,8 +237,6 @@
   std::size_t minElemLen{MinElemLen(type)};
   if (minElemLen > 0) {
     elem_len = minElemLen;
-  } else if (elem_len <= 0) {
-    return CFI_INVALID_ELEM_LEN;
   }
   descriptor->base_addr = base_addr;
   descriptor->elem_len = elem_len;


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D99296.333107.patch
Type: text/x-patch
Size: 459 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210324/f9a085a7/attachment.bin>


More information about the llvm-commits mailing list