Commit 182e2dee84b7d9270a748ff70762a9933f8ef462

Thomas de Grivel 2023-11-30T15:35:10

fix buf_init_str

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
diff --git a/libc3/buf.c b/libc3/buf.c
index d767e12..0156e9a 100644
--- a/libc3/buf.c
+++ b/libc3/buf.c
@@ -230,7 +230,11 @@ s_buf * buf_init_alloc (s_buf *buf, uw size)
 
 s_buf * buf_init_str (s_buf *buf, bool p_free, s_str *p)
 {
-  return buf_init(buf, p_free, p->size, (s8 *) p->ptr.ps8);
+  assert(buf);
+  assert(p);
+  buf_init(buf, p_free, p->size, (s8 *) p->ptr.ps8);
+  buf->wpos = p->size;
+  return buf;
 }
 
 s_buf * buf_init_str_copy (s_buf *buf, const s_str *str)