From b9fddc9244da97d38b2fea80c69b0348a9b53d96 Mon Sep 17 00:00:00 2001 From: Ben Pfaff Date: Mon, 29 Dec 2008 13:26:19 -0800 Subject: [PATCH] Make ds_cstr() always null-terminate the string. Most of the time the string in "struct ds" is null-terminated, but there seem to be a few corner cases where it is not. Make ds_cstr() always put in the null terminator, for safety. Thanks to Justin for pointing out the problem. --- lib/dynamic-string.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/dynamic-string.c b/lib/dynamic-string.c index 2fe8cfb6e..1df85ac31 100644 --- a/lib/dynamic-string.c +++ b/lib/dynamic-string.c @@ -177,8 +177,8 @@ ds_cstr(struct ds *ds) { if (!ds->string) { ds_reserve(ds, 0); - ds->string[0] = '\0'; } + ds->string[ds->length] = '\0'; return ds->string; } -- 2.43.0