user.exe16: Fix an incorrect use of ADD_TO_T in FormatMessage16.

Gerald Pfeifer gerald at pfeifer.com
Sun Jul 9 11:53:50 CDT 2017


ADD_TO_T actually consists of two statements

  #define ADD_TO_T(c) \
        *t++=c;\
        if (t-target == talloced) {\
                target  = HeapReAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,target,talloced*2);\
                t       = target+talloced;\
                talloced*=2;\
        }

so  

  for (x=b; *x; x++) ADD_TO_T(*x);

does _not_ actually do what one might expect/hope.

Fixed thusly, in line with other usage.

Signed-off-by: Gerald Pfeifer <gerald at pfeifer.com>
---
 dlls/user.exe16/user.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/dlls/user.exe16/user.c b/dlls/user.exe16/user.c
index 267714a6d8..b2c153e13f 100644
--- a/dlls/user.exe16/user.c
+++ b/dlls/user.exe16/user.c
@@ -3251,7 +3251,9 @@ DWORD WINAPI FormatMessage16(
                             if (!new_b) break;
                             b = new_b;
                         }
-                        for (x=b; *x; x++) ADD_TO_T(*x);
+                        for (x=b; *x; x++) {
+                            ADD_TO_T(*x);
+                        }
                         HeapFree(GetProcessHeap(), 0, b);
                     } else {
                         /* NULL args - copy formatstr
-- 
2.13.0



More information about the wine-patches mailing list