Skip to content

Commit

Permalink
Fix heap buffer overflow in function yaml_emitter_emit_flow_sequence_…
Browse files Browse the repository at this point in the history
…item, releated issue:yaml#258
  • Loading branch information
ziyangc committed Nov 25, 2022
1 parent f8f760f commit 44a285a
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/emitter.c
Original file line number Diff line number Diff line change
Expand Up @@ -758,8 +758,14 @@ yaml_emitter_emit_flow_sequence_item(yaml_emitter_t *emitter,
if (event->type == YAML_SEQUENCE_END_EVENT)
{
emitter->flow_level --;
emitter->indent = POP(emitter, emitter->indents);
if (emitter->canonical && !first) {
if (!STACK_EMPTY(emitter, emitter->indents)) {
emitter->indent = POP(emitter, emitter->indents);
}
else {
emitter->indent = 0; // set to default
}

if (emitter->canonical && !first) {
if (!yaml_emitter_write_indicator(emitter, ",", 0, 0, 0))
return 0;
if (!yaml_emitter_write_indent(emitter))
Expand Down

0 comments on commit 44a285a

Please sign in to comment.