diff --git a/libguile/strings.c b/libguile/strings.c index 137ad5d09..1f3094dc6 100644 --- a/libguile/strings.c +++ b/libguile/strings.c @@ -122,12 +122,12 @@ make_stringbuf (size_t len) } } -/* Return a new stringbuf whose underlying storage consists of the LEN octets - pointed to by STR. */ +/* Return a new stringbuf whose underlying storage consists of the LEN+1 + octets pointed to by STR (the last octet is zero). */ SCM_C_INLINE SCM scm_i_take_stringbufn (char *str, size_t len) { - scm_gc_register_collectable_memory (str, len, "stringbuf"); + scm_gc_register_collectable_memory (str, len + 1, "stringbuf"); return scm_double_cell (STRINGBUF_TAG, (scm_t_bits) str, (scm_t_bits) len, (scm_t_bits) 0);