Fix out of bounds access in hasStructRetAttr
authorSanjoy Das <sanjoy@playingwithpointers.com>
Sun, 29 Nov 2015 23:15:43 +0000 (23:15 +0000)
committerSanjoy Das <sanjoy@playingwithpointers.com>
Sun, 29 Nov 2015 23:15:43 +0000 (23:15 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@254273 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/IR/Instructions.h

index a5a48cb30b05a087090181d44ccec04ba9461d2e..5119749ba73ce2a4c1cd4e193f6d7d7ca9eac7f5 100644 (file)
@@ -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);
   }