Make ds_cstr() always null-terminate the string.
[sliver-openvswitch.git] / lib / dynamic-string.c
index 2fe8cfb..1df85ac 100644 (file)
@@ -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;
 }