From 99ca35977ce22dfd14e63927ce974251b54f5cfb Mon Sep 17 00:00:00 2001 From: John Marshall Date: Wed, 24 Jul 2013 14:08:25 +0100 Subject: [PATCH] Only canonicalise if there is room, and add docs We could increment SIZE to ensure there would be room, but that would disadvantage people using kstrings for binary data in power-of-2-sized blocks. Instead document that SIZE=KS.l+1 will ensure NUL-termination. This fixes a bug in the previous version when the lm < size) { @@ -89,7 +92,7 @@ static inline int ks_resize(kstring_t *s, size_t size) else return -1; } - s->s[s->l] = '\0'; + if (s->l < s->m) s->s[s->l] = '\0'; return 0; } -- 2.47.3