user.exe16: Make ADD_TO_T more resilient to use.

Gerald Pfeifer gerald at pfeifer.com
Sun Jul 9 12:06:15 CDT 2017


This is related to the patch I sent a few minutes ago and makes
the ADD_TO_T macro more resilient. 

It appears prudent (and resilient) to make both changes.

Gerald

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

diff --git a/dlls/user.exe16/user.c b/dlls/user.exe16/user.c
index b2c153e13f..a8f45ac2cd 100644
--- a/dlls/user.exe16/user.c
+++ b/dlls/user.exe16/user.c
@@ -3179,12 +3179,14 @@ DWORD WINAPI FormatMessage16(
     talloced= 100;
 
 #define ADD_TO_T(c) \
-        *t++=c;\
-        if (t-target == talloced) {\
+        do { \
+            *t++=c;\
+            if (t-target == talloced) {\
                 target  = HeapReAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,target,talloced*2);\
                 t       = target+talloced;\
                 talloced*=2;\
-        }
+            } \
+        } while(0);
 
     if (from) {
         f=from;
-- 
2.13.0



More information about the wine-patches mailing list