* fix #63

* rather patch the context in case of corruption
This commit is contained in:
Basile Burg 2017-05-31 09:59:27 +02:00 committed by GitHub
parent 3a01837c72
commit aab7c7aabe

View file

@ -208,6 +208,9 @@ struct Emitter
while(!needMoreEvents()) while(!needMoreEvents())
{ {
event_ = events_.pop(); event_ = events_.pop();
// copy construction and move semantic can
// exceptionally lead to wrong delegate context.
state_.ptr = &this;
state_(); state_();
event_.destroy(); event_.destroy();
} }
@ -606,7 +609,7 @@ struct Emitter
//Block sequence handlers. //Block sequence handlers.
///Handle a block sequence. ///Handle a block sequence.
void expectBlockSequence() @safe void expectBlockSequence() @trusted
{ {
const indentless = (context_ == Context.MappingNoSimpleKey || const indentless = (context_ == Context.MappingNoSimpleKey ||
context_ == Context.MappingSimpleKey) && !indentation_; context_ == Context.MappingSimpleKey) && !indentation_;
@ -633,7 +636,7 @@ struct Emitter
//Block mapping handlers. //Block mapping handlers.
///Handle a block mapping. ///Handle a block mapping.
void expectBlockMapping() @safe void expectBlockMapping() @trusted
{ {
increaseIndent(No.flow); increaseIndent(No.flow);
state_ = &expectBlockMappingKey!(Yes.first); state_ = &expectBlockMappingKey!(Yes.first);