testbot/testagentd: Fix the buffer reallocation in vset_status().

Francois Gouget fgouget at codeweavers.com
Fri Nov 30 05:15:04 CST 2012


---
 testbot/src/testagentd/testagentd.c |    7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/testbot/src/testagentd/testagentd.c b/testbot/src/testagentd/testagentd.c
index 4d5a13e..4973fd5 100644
--- a/testbot/src/testagentd/testagentd.c
+++ b/testbot/src/testagentd/testagentd.c
@@ -190,12 +190,15 @@ static void vset_status(const char* format, va_list valist)
 {
     int len;
     va_list args;
-    len = 1;
+    len = 0;
     do
     {
         if (len >= status_size)
         {
-            status_size = (len +0xf) & ~0xf;
+            /* len does not count the trailing '\0'. So add 1 and round up
+             * to the next 16 bytes multiple.
+             */
+            status_size = (len + 1 + 0xf) & ~0xf;
             status = realloc(status, status_size);
         }
         va_copy(args, valist);
-- 
1.7.10.4




More information about the wine-patches mailing list