зеркало из https://github.com/mozilla/gecko-dev.git
Bug 539856: Avoid use-after-free of |mId| when constructing replies to destructor messages by saving |mId| on the stack. no r=, minor
This commit is contained in:
Родитель
6e33770c22
Коммит
8d8174a707
|
@ -3513,6 +3513,7 @@ class _GenerateProtocolActorCode(ipdl.ast.Visitor):
|
|||
failif = StmtIf(ExprNot(readok))
|
||||
failif.addifstmt(StmtReturn(_Result.PayloadError))
|
||||
|
||||
idvar = ExprVar('__id')
|
||||
case.addstmts(
|
||||
stmts
|
||||
+ [ failif, Whitespace.NL ]
|
||||
|
@ -3520,8 +3521,11 @@ class _GenerateProtocolActorCode(ipdl.ast.Visitor):
|
|||
for r in md.returns ]
|
||||
+ self.invokeRecvHandler(md, implicit=0)
|
||||
+ [ Whitespace.NL ]
|
||||
+ [ StmtDecl(Decl(_actorIdType(), idvar.name),
|
||||
self.protocol.routingId()) ]
|
||||
+ self.dtorEpilogue(md, md.actorDecl().var())
|
||||
+ self.makeReply(md, errfnRecv)
|
||||
+ [ Whitespace.NL ]
|
||||
+ self.makeReply(md, errfnRecv, routingId=idvar)
|
||||
+ [ Whitespace.NL,
|
||||
StmtReturn(_Result.Processed) ])
|
||||
|
||||
|
@ -3572,16 +3576,17 @@ class _GenerateProtocolActorCode(ipdl.ast.Visitor):
|
|||
msgCtorArgs.append(arg)
|
||||
stmts.extend(sstmts)
|
||||
|
||||
routingId = self.protocol.routingId(fromActor)
|
||||
stmts.extend([
|
||||
StmtExpr(ExprAssn(
|
||||
msgvar,
|
||||
ExprNew(Type(md.pqMsgClass()), args=msgCtorArgs))) ]
|
||||
+ self.setMessageFlags(md, msgvar, reply=0, actor=fromActor))
|
||||
+ self.setMessageFlags(md, msgvar, reply=0, routingId=routingId))
|
||||
|
||||
return msgvar, stmts
|
||||
|
||||
|
||||
def makeReply(self, md, errfn):
|
||||
def makeReply(self, md, errfn, routingId=None):
|
||||
# TODO special cases for async ctor/dtor replies
|
||||
if md.decl.type.isAsync():
|
||||
return [ ]
|
||||
|
@ -3598,16 +3603,19 @@ class _GenerateProtocolActorCode(ipdl.ast.Visitor):
|
|||
StmtExpr(ExprAssn(
|
||||
replyvar,
|
||||
ExprNew(Type(md.pqReplyClass()), args=replyCtorArgs))) ]
|
||||
+ self.setMessageFlags(md, replyvar, reply=1)
|
||||
+ self.setMessageFlags(md, replyvar, reply=1, routingId=routingId)
|
||||
+[ self.logMessage(md, md.replyCast(replyvar), 'Sending reply ') ])
|
||||
|
||||
return stmts
|
||||
|
||||
|
||||
def setMessageFlags(self, md, var, reply, actor=None):
|
||||
def setMessageFlags(self, md, var, reply, routingId=None):
|
||||
if routingId is None:
|
||||
routingId = self.protocol.routingId()
|
||||
|
||||
stmts = [ StmtExpr(ExprCall(
|
||||
ExprSelect(var, '->', 'set_routing_id'),
|
||||
args=[ self.protocol.routingId(actor) ])) ]
|
||||
args=[ routingId ])) ]
|
||||
|
||||
if md.decl.type.isSync():
|
||||
stmts.append(StmtExpr(ExprCall(
|
||||
|
|
Загрузка…
Ссылка в новой задаче