OSDN Git Service

[Support] Fix error handling in DataExtractor::get[US]LEB128
authorPavel Labath <pavel@labath.sk>
Mon, 24 Jun 2019 09:11:24 +0000 (09:11 +0000)
committerPavel Labath <pavel@labath.sk>
Mon, 24 Jun 2019 09:11:24 +0000 (09:11 +0000)
commitcd63a636640c38d530aaa12476fc03ab7372f6a9
treec20014e4007d86b7ad3e42957c6347e4536d4251
parent2c64704a921f6a3766f95aba4ad3cb3a76d6d960
[Support] Fix error handling in DataExtractor::get[US]LEB128

Summary:
These functions are documented as not modifying the offset argument if
the extraction fails (just like other DataExtractor functions). However,
while reviewing D63591 we discovered that this is not the case -- if the
function reaches the end of the data buffer, it will just return the
value parsed until that point and set offset to point to the end of the
buffer.

This fixes the functions to act as advertised, and adds a regression
test.

Reviewers: dblaikie, probinson, bkramer

Subscribers: kristina, llvm-commits

Tags: #llvm

Differential Revision: https://reviews.llvm.org/D63645

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@364169 91177308-0d34-0410-b5e6-96231b3b80d8
lib/Support/DataExtractor.cpp
unittests/Support/DataExtractorTest.cpp