[llvm] r252617 - Fix asan warning (NFC)
David Blaikie via llvm-commits
llvm-commits at lists.llvm.org
Tue Nov 10 09:45:25 PST 2015
On Tue, Nov 10, 2015 at 9:11 AM, Xinliang David Li via llvm-commits <
llvm-commits at lists.llvm.org> wrote:
> Author: davidxl
> Date: Tue Nov 10 11:11:33 2015
> New Revision: 252617
>
> URL: http://llvm.org/viewvc/llvm-project?rev=252617&view=rev
> Log:
> Fix asan warning (NFC)
>
> Modified:
> llvm/trunk/lib/ProfileData/InstrProf.cpp
>
> Modified: llvm/trunk/lib/ProfileData/InstrProf.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/ProfileData/InstrProf.cpp?rev=252617&r1=252616&r2=252617&view=diff
>
> ==============================================================================
> --- llvm/trunk/lib/ProfileData/InstrProf.cpp (original)
> +++ llvm/trunk/lib/ProfileData/InstrProf.cpp Tue Nov 10 11:11:33 2015
> @@ -247,8 +247,9 @@ void ValueProfData::deserializeTo(InstrP
> std::unique_ptr<ValueProfData>
> ValueProfData::serializeFrom(const InstrProfRecord &Record) {
> uint32_t TotalSize = getSize(Record);
> - std::unique_ptr<ValueProfData> VPD(
> - reinterpret_cast<ValueProfData *>(new char[TotalSize]));
> + void *RawMem = ::operator new(TotalSize);
> + ValueProfData *VPDMem = new (RawMem) ValueProfData();
> + std::unique_ptr<ValueProfData> VPD(VPDMem);
>
This still seems incorrect though, no? The object was allocated with op
new, but will be freed with delete on ValueProfData*?
(CC'ing Richard Smith in case he's time to weigh in here)
>
> VPD->TotalSize = TotalSize;
> VPD->NumValueKinds = Record.getNumValueKinds();
>
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20151110/d5b18e9b/attachment.html>
More information about the llvm-commits
mailing list