Commit c2564d34 authored by Pavel Tvrdik's avatar Pavel Tvrdik Committed by Ondřej Zajíček

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
......@@ -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;
......
......@@ -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;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment