Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(424)

Side by Side Diff: lib/Bitcode/NaCl/Reader/NaClBitcodeReader.cpp

Issue 932953002: Fix the NaCl bitstream reader to report fatal errors. (Closed) Base URL: https://chromium.googlesource.com/native_client/pnacl-llvm.git@master
Patch Set: Fix formatting. Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 //===- NaClBitcodeReader.cpp ----------------------------------------------===// 1 //===- NaClBitcodeReader.cpp ----------------------------------------------===//
2 // Internal NaClBitcodeReader implementation 2 // Internal NaClBitcodeReader implementation
3 // 3 //
4 // The LLVM Compiler Infrastructure 4 // The LLVM Compiler Infrastructure
5 // 5 //
6 // This file is distributed under the University of Illinois Open Source 6 // This file is distributed under the University of Illinois Open Source
7 // License. See LICENSE.TXT for details. 7 // License. See LICENSE.TXT for details.
8 // 8 //
9 //===----------------------------------------------------------------------===// 9 //===----------------------------------------------------------------------===//
10 10
(...skipping 1833 matching lines...) Expand 10 before | Expand all | Expand 10 after
1844 } 1844 }
1845 1845
1846 std::error_code NaClBitcodeReader::InitStreamFromBuffer() { 1846 std::error_code NaClBitcodeReader::InitStreamFromBuffer() {
1847 const unsigned char *BufPtr = (const unsigned char*)Buffer->getBufferStart(); 1847 const unsigned char *BufPtr = (const unsigned char*)Buffer->getBufferStart();
1848 const unsigned char *BufEnd = BufPtr+Buffer->getBufferSize(); 1848 const unsigned char *BufEnd = BufPtr+Buffer->getBufferSize();
1849 1849
1850 if (Buffer->getBufferSize() & 3) 1850 if (Buffer->getBufferSize() & 3)
1851 return Error(InvalidBitstream, 1851 return Error(InvalidBitstream,
1852 "Bitcode stream should be a multiple of 4 bytes in length"); 1852 "Bitcode stream should be a multiple of 4 bytes in length");
1853 1853
1854 if (Header.Read(BufPtr, BufEnd)) 1854 const unsigned char *HeaderPtr = BufPtr;
1855 if (Header.Read(HeaderPtr, BufEnd))
1855 return Error(InvalidBitstream, Header.Unsupported()); 1856 return Error(InvalidBitstream, Header.Unsupported());
1856 1857
1857 StreamFile.reset(new NaClBitstreamReader(BufPtr, BufEnd)); 1858 StreamFile.reset(new NaClBitstreamReader(BufPtr, BufEnd,
1859 Header.getHeaderSize()));
1858 Stream.init(StreamFile.get()); 1860 Stream.init(StreamFile.get());
1859 1861
1860 if (AcceptHeader()) 1862 if (AcceptHeader())
1861 return Error(InvalidBitstream, Header.Unsupported()); 1863 return Error(InvalidBitstream, Header.Unsupported());
1862 return std::error_code(); 1864 return std::error_code();
1863 } 1865 }
1864 1866
1865 std::error_code NaClBitcodeReader::InitLazyStream() { 1867 std::error_code NaClBitcodeReader::InitLazyStream() {
1866 if (Header.Read(LazyStreamer)) 1868 if (Header.Read(LazyStreamer))
1867 return Error(InvalidBitstream, Header.Unsupported()); 1869 return Error(InvalidBitstream, Header.Unsupported());
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
1937 Materializer->releaseBuffer(); 1939 Materializer->releaseBuffer();
1938 delete M; 1940 delete M;
1939 return EC; 1941 return EC;
1940 } 1942 }
1941 1943
1942 // TODO: Restore the use-lists to the in-memory state when the bitcode was 1944 // TODO: Restore the use-lists to the in-memory state when the bitcode was
1943 // written. We must defer until the Module has been fully materialized. 1945 // written. We must defer until the Module has been fully materialized.
1944 1946
1945 return M; 1947 return M;
1946 } 1948 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698