Skip to content

Commit fbb11b4

Browse files
authored
[OpenMP][Flang] Fix OOB access for derived type mapping (llvm#140948)
1 parent d6f394e commit fbb11b4

File tree

1 file changed

+12
-10
lines changed

1 file changed

+12
-10
lines changed

flang/lib/Lower/OpenMP/Utils.cpp

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -362,16 +362,18 @@ mlir::Value createParentSymAndGenIntermediateMaps(
362362
clauseLocation, firOpBuilder.getRefType(memberTy), curValue,
363363
llvm::SmallVector<fir::IntOrValue, 1>{idxConst});
364364

365-
// Skip mapping and the subsequent load if we're the final member or not
366-
// a type with a descriptor such as a pointer/allocatable. If we're a
367-
// final member, the map will be generated by the processMap call that
368-
// invoked this function, and if we're not a type with a descriptor then
369-
// we have no need of generating an intermediate map for it, as we only
370-
// need to generate a map if a member is a descriptor type (and thus
371-
// obscures the members it contains via a pointer in which it's data needs
372-
// mapped)
373-
if ((currentIndicesIdx == indices.size() - 1) ||
374-
!fir::isTypeWithDescriptor(memberTy)) {
365+
// If we're a final member, the map will be generated by the processMap
366+
// call that invoked this function.
367+
if (currentIndicesIdx == indices.size() - 1)
368+
break;
369+
370+
// Skip mapping and the subsequent load if we're not
371+
// a type with a descriptor such as a pointer/allocatable. If we're not a
372+
// type with a descriptor then we have no need of generating an
373+
// intermediate map for it, as we only need to generate a map if a member
374+
// is a descriptor type (and thus obscures the members it contains via a
375+
// pointer in which it's data needs mapped).
376+
if (!fir::isTypeWithDescriptor(memberTy)) {
375377
currentIndicesIdx++;
376378
continue;
377379
}

0 commit comments

Comments
 (0)