[llvm] r254273 - Fix out of bounds access in hasStructRetAttr

Sanjoy Das via llvm-commits llvm-commits at lists.llvm.org
Sun Nov 29 15:15:44 PST 2015


Author: sanjoy
Date: Sun Nov 29 17:15:43 2015
New Revision: 254273

URL: http://llvm.org/viewvc/llvm-project?rev=254273&view=rev
Log:
Fix out of bounds access in hasStructRetAttr

Modified:
    llvm/trunk/include/llvm/IR/Instructions.h

Modified: llvm/trunk/include/llvm/IR/Instructions.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/IR/Instructions.h?rev=254273&r1=254272&r2=254273&view=diff
==============================================================================
--- llvm/trunk/include/llvm/IR/Instructions.h (original)
+++ llvm/trunk/include/llvm/IR/Instructions.h Sun Nov 29 17:15:43 2015
@@ -1730,6 +1730,9 @@ public:
   /// \brief Determine if the call returns a structure through first
   /// pointer argument.
   bool hasStructRetAttr() const {
+    if (getNumArgOperands() == 0)
+      return false;
+
     // Be friendly and also check the callee.
     return paramHasAttr(1, Attribute::StructRet);
   }
@@ -3614,6 +3617,9 @@ public:
   /// \brief Determine if the call returns a structure through first
   /// pointer argument.
   bool hasStructRetAttr() const {
+    if (getNumArgOperands() == 0)
+      return false;
+
     // Be friendly and also check the callee.
     return paramHasAttr(1, Attribute::StructRet);
   }




More information about the llvm-commits mailing list