[llvm] r268896 - [mips][microMIPS] Implement LWP and SWP instructions

Daniel Sanders via llvm-commits llvm-commits at lists.llvm.org
Mon May 9 06:27:22 PDT 2016


> > @@ -4673,9 +4692,9 @@ MipsAsmParser::parseRegisterPair(Operand
> >
> >    SMLoc E = Parser.getTok().getLoc();
> >    MipsOperand &Op = static_cast<MipsOperand &>(*Operands.back());
> > -  unsigned Reg = Op.getGPR32Reg();
> > +
> >    Operands.pop_back();
> > -  Operands.push_back(MipsOperand::CreateRegPair(Reg, S, E, *this));
> > +  Operands.push_back(MipsOperand::CreateRegPair(Op, S, E, *this));
> 
> There's a use after free here because Op is still bound to
> Operands.back().  I tried to fix in r268901, but it broke tests. Can you take a look?

I've applied a quick fix for this in r268913. Op is now a copy of the last element so that Op isn't deleted when pop_back() causes std::unique_ptr<MipsOperand> to delete Operands.back().

I'm not sure why your fix didn't work. It looked ok to me.


More information about the llvm-commits mailing list