[PATCH] D26638: Don't pass nullptr into memcpy

Zachary Turner via llvm-commits llvm-commits at lists.llvm.org
Mon Nov 14 14:45:57 PST 2016


Data.size() is unsigned type.  negative will overflow, so the comparison
will never be true.  Maybe I don't follow what you guys are seeing.
Anyway, if you attempt to write 0 bytes, I think it should succeed.  So the
early return still looks fine to me, regardless of what it was doing before.

On Mon, Nov 14, 2016 at 2:40 PM Vitaly Buka <vitalybuka at google.com> wrote:

> vitalybuka added a comment.
>
> Majnemer, You are right
> // here if Buffer is empty:
> if (Offset > - Data.size())
>
>   return make_error<MSFError>(msf_error_code::insufficient_buffer);
>
> so it's essentially if (Offset >0 || Data.size() >0 )
>
> I should submit the first patch which I've changed in the last moment for
> "early return" :-)
>
>
> Repository:
>   rL LLVM
>
> https://reviews.llvm.org/D26638
>
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20161114/810bbad1/attachment.html>


More information about the llvm-commits mailing list