From: Filipe Cabecinhas Date: Wed, 29 Apr 2015 02:27:28 +0000 (+0000) Subject: Check that we have a valid PointerType element type before calling get() X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=99ebc9e0046475e40d4d72c0c13612331786664a;p=oota-llvm.git Check that we have a valid PointerType element type before calling get() Same as r236073 but for PointerType. Bug found with AFL fuzz. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@236079 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Bitcode/Reader/BitcodeReader.cpp b/lib/Bitcode/Reader/BitcodeReader.cpp index 8141d5673bd..f11eba51e6c 100644 --- a/lib/Bitcode/Reader/BitcodeReader.cpp +++ b/lib/Bitcode/Reader/BitcodeReader.cpp @@ -1360,7 +1360,8 @@ std::error_code BitcodeReader::ParseTypeTableBody() { if (Record.size() == 2) AddressSpace = Record[1]; ResultTy = getTypeByID(Record[0]); - if (!ResultTy) + if (!ResultTy || + !PointerType::isValidElementType(ResultTy)) return Error("Invalid type"); ResultTy = PointerType::get(ResultTy, AddressSpace); break; diff --git a/test/Bitcode/Inputs/invalid-pointer-element-type.bc b/test/Bitcode/Inputs/invalid-pointer-element-type.bc new file mode 100644 index 00000000000..f9649e66429 Binary files /dev/null and b/test/Bitcode/Inputs/invalid-pointer-element-type.bc differ diff --git a/test/Bitcode/invalid.test b/test/Bitcode/invalid.test index 41173d17e5d..c18ff3d3f61 100644 --- a/test/Bitcode/invalid.test +++ b/test/Bitcode/invalid.test @@ -103,6 +103,8 @@ RUN: not llvm-dis -disable-output %p/Inputs/invalid-array-element-type.bc 2>&1 | RUN: FileCheck --check-prefix=ELEMENT-TYPE %s RUN: not llvm-dis -disable-output %p/Inputs/invalid-vector-element-type.bc 2>&1 | \ RUN: FileCheck --check-prefix=ELEMENT-TYPE %s +RUN: not llvm-dis -disable-output %p/Inputs/invalid-pointer-element-type.bc 2>&1 | \ +RUN: FileCheck --check-prefix=ELEMENT-TYPE %s ELEMENT-TYPE: Invalid type