Commit c2564d34 authored by Pavel Tvrdik's avatar Pavel Tvrdik Committed by Ondrej Zajicek (work)
Browse files

Tree/Trie: Check the end of buffer

We set buffer->pos to buffer->end in function buffer_print() when
bvsnprintf() failed, so there would be uninitialized memory between
the old buffer->pos and the current buffer->pos.
parent 7935b9d2
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -165,6 +165,9 @@ tree_format(struct f_tree *t, buffer *buf)
 
  tree_node_format(t, buf);

  if (buf->pos == buf->end)
    return;

  /* Undo last separator */
  if (buf->pos[-1] != '[')
    buf->pos -= 2;
+3 −0
Original line number Diff line number Diff line
@@ -300,6 +300,9 @@ trie_format(struct f_trie *t, buffer *buf)
    buffer_print(buf, "%I/%d, ", IPA_NONE, 0);
  trie_node_format(t->root, buf);

  if (buf->pos == buf->end)
    return;

  /* Undo last separator */
  if (buf->pos[-1] != '[')
    buf->pos -= 2;