From: John Marshall Date: Tue, 23 Jul 2013 15:16:19 +0000 (+0100) Subject: ks_resize() canonicalises the stored string X-Git-Tag: spawn-final~20^2~2 X-Git-Url: http://www.kaiwu.me/postgresql/commit/static/gitweb.js?a=commitdiff_plain;h=e1c00506671062bea47166f4ee77068d8bdb8b12;p=klib.git ks_resize() canonicalises the stored string It ensures the string is NUL-terminated, especially in the case that ks_resize(&kstr,1) has been used on a newly-created kstring_t to ensure that kstr.s is not NULL. --- diff --git a/kstring.h b/kstring.h index da53ba6..4c803b8 100644 --- a/kstring.h +++ b/kstring.h @@ -89,6 +89,7 @@ static inline int ks_resize(kstring_t *s, size_t size) else return -1; } + s->s[s->l] = '\0'; return 0; }