[ovs-dev] [PATCH] dynamic-string: Fix a bug that leads to assertion fail

Yifeng Sun pkusunyifeng at gmail.com
Tue Jul 24 15:37:08 UTC 2018


'needed' should be size of needed memory space beyond allocated.

Signed-off-by: Yifeng Sun <pkusunyifeng at gmail.com>
Reported-by: Yun Zhou <yunz at nvidia.com>
Reported-by: Girish Moodalbail <gmoodalbail at gmail.com>
---
 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 6f7b610a9908..4564e420544d 100644
--- a/lib/dynamic-string.c
+++ b/lib/dynamic-string.c
@@ -158,7 +158,7 @@ ds_put_format_valist(struct ds *ds, const char *format, va_list args_)
     if (needed < available) {
         ds->length += needed;
     } else {
-        ds_reserve(ds, ds->length + needed);
+        ds_reserve(ds, ds->allocated + needed);
 
         va_copy(args, args_);
         available = ds->allocated - ds->length + 1;
-- 
2.7.4



More information about the dev mailing list