From 7b83761ef4216d841f259264d2689a63edfd5c0a Mon Sep 17 00:00:00 2001 From: Patrick Pelissier Date: Sun, 17 Feb 2019 21:38:27 +0100 Subject: [PATCH] Update --- m-string.h | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/m-string.h b/m-string.h index d134de24..3d399d44 100644 --- a/m-string.h +++ b/m-string.h @@ -102,9 +102,10 @@ string_int_stack_p(const string_t s) static inline void string_int_set_size(string_t s, size_t size) { - if (string_int_stack_p(s)) + if (string_int_stack_p(s)) { + assert (size < sizeof (str_heap_t) - 1); s->u.stack.buffer[0] = size; - else + } else s->u.heap.size = size; } @@ -214,7 +215,7 @@ stringi_fit2size (string_t v, size_t size_alloc) return; } if (string_int_stack_p(v)) { - memcpy(ptr, v->ptr, old_alloc); + memcpy(ptr, &v->u.stack.buffer[1], v->u.stack.buffer[0]+1); } v->ptr = ptr; v->u.heap.alloc = alloc;