[PATCH] msvcrt: Fix precision handling for string arguments.

Józef Kucia jkucia at codeweavers.com
Thu Aug 17 05:48:08 CDT 2017


Signed-off-by: Józef Kucia <jkucia at codeweavers.com>
---

The wide string version needs the same fix as well.

---
 dlls/msvcrt/printf.h | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/dlls/msvcrt/printf.h b/dlls/msvcrt/printf.h
index 8bb3382b39..d868e64359 100644
--- a/dlls/msvcrt/printf.h
+++ b/dlls/msvcrt/printf.h
@@ -190,8 +190,13 @@ static inline int FUNC_NAME(pf_output_format_str)(FUNC_NAME(puts_clbk) pf_puts,
 {
     int r, ret;
 
-    if(len < 0)
-        len = strlen(str);
+    if(len < 0) {
+        /* Do not search past the length specified by the precision. */
+        if(flags->Precision>=0)
+            len = strnlen(str, flags->Precision);
+        else
+            len = strlen(str);
+    }
 
     if(flags->Precision>=0 && flags->Precision<len)
         len = flags->Precision;
-- 
2.13.0




More information about the wine-patches mailing list