<div dir="ltr">I took a quick look at DebugInfo/DataExtractor, and the getULEB128 there is correct (it has the uint64_t conversion).<div>But the question is why is the LEB128 decoding code is duplicated?</div></div><div class="gmail_extra">
<br><br><div class="gmail_quote">2014-08-22 11:04 GMT-07:00 David Blaikie <span dir="ltr"><<a href="mailto:dblaikie@gmail.com" target="_blank">dblaikie@gmail.com</a>></span>:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
So this scares me a bit - not because this fix isn't right (it looks<br>
right to me) but because this isn't the only code that does (U)LEB<br>
conversions. I think there's a couple of copies in debug info code...<br>
<br>
Could you check for them? Or I can try to dredge them up & take a glance.<br>
<div class="HOEnZb"><div class="h5"><br>
On Fri, Aug 22, 2014 at 9:29 AM, Alex Lorenz <<a href="mailto:arphaman@gmail.com">arphaman@gmail.com</a>> wrote:<br>
> Author: arphaman<br>
> Date: Fri Aug 22 11:29:45 2014<br>
> New Revision: 216268<br>
><br>
> URL: <a href="http://llvm.org/viewvc/llvm-project?rev=216268&view=rev" target="_blank">http://llvm.org/viewvc/llvm-project?rev=216268&view=rev</a><br>
> Log:<br>
> [Support] Fix the overflow bug in ULEB128 decoding.<br>
><br>
> Differential Revision: <a href="http://reviews.llvm.org/D5029" target="_blank">http://reviews.llvm.org/D5029</a><br>
><br>
> Modified:<br>
>     llvm/trunk/include/llvm/Support/LEB128.h<br>
>     llvm/trunk/unittests/Support/LEB128Test.cpp<br>
><br>
> Modified: llvm/trunk/include/llvm/Support/LEB128.h<br>
> URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/LEB128.h?rev=216268&r1=216267&r2=216268&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/LEB128.h?rev=216268&r1=216267&r2=216268&view=diff</a><br>

> ==============================================================================<br>
> --- llvm/trunk/include/llvm/Support/LEB128.h (original)<br>
> +++ llvm/trunk/include/llvm/Support/LEB128.h Fri Aug 22 11:29:45 2014<br>
> @@ -82,7 +82,7 @@ inline uint64_t decodeULEB128(const uint<br>
>    uint64_t Value = 0;<br>
>    unsigned Shift = 0;<br>
>    do {<br>
> -    Value += (*p & 0x7f) << Shift;<br>
> +    Value += uint64_t(*p & 0x7f) << Shift;<br>
>      Shift += 7;<br>
>    } while (*p++ >= 128);<br>
>    if (n)<br>
><br>
> Modified: llvm/trunk/unittests/Support/LEB128Test.cpp<br>
> URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/unittests/Support/LEB128Test.cpp?rev=216268&r1=216267&r2=216268&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/unittests/Support/LEB128Test.cpp?rev=216268&r1=216267&r2=216268&view=diff</a><br>

> ==============================================================================<br>
> --- llvm/trunk/unittests/Support/LEB128Test.cpp (original)<br>
> +++ llvm/trunk/unittests/Support/LEB128Test.cpp Fri Aug 22 11:29:45 2014<br>
> @@ -106,6 +106,7 @@ TEST(LEB128Test, DecodeULEB128) {<br>
>    EXPECT_DECODE_ULEB128_EQ(0xffu, "\xff\x01");<br>
>    EXPECT_DECODE_ULEB128_EQ(0x100u, "\x80\x02");<br>
>    EXPECT_DECODE_ULEB128_EQ(0x101u, "\x81\x02");<br>
> +  EXPECT_DECODE_ULEB128_EQ(4294975616ULL, "\x80\xc1\x80\x80\x10");<br>
><br>
>    // Decode ULEB128 with extra padding bytes<br>
>    EXPECT_DECODE_ULEB128_EQ(0u, "\x80\x00");<br>
><br>
><br>
> _______________________________________________<br>
> llvm-commits mailing list<br>
> <a href="mailto:llvm-commits@cs.uiuc.edu">llvm-commits@cs.uiuc.edu</a><br>
> <a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits</a><br>
</div></div></blockquote></div><br></div>