[PATCH 1/2] msvcrt: Handle NULL as format string
Detlef Riekenberg
wine.dev at web.de
Wed Jul 6 15:03:03 CDT 2011
This let a win7 game avoid a crash and go a bit further
---
dlls/msvcrt/printf.h | 5 +++++
dlls/msvcrt/wcs.c | 2 +-
2 files changed, 6 insertions(+), 1 deletions(-)
diff --git a/dlls/msvcrt/printf.h b/dlls/msvcrt/printf.h
index ca7870c..dbeaf58 100644
--- a/dlls/msvcrt/printf.h
+++ b/dlls/msvcrt/printf.h
@@ -348,6 +348,11 @@ int FUNC_NAME(pf_printf)(FUNC_NAME(puts_clbk) pf_puts, void *puts_ctx, const API
TRACE("Format is: %s\n", FUNC_NAME(debugstr)(fmt));
+ if (!p) {
+ WARN("format is null\n");
+ return -1;
+ }
+
if(!locale)
locinfo = get_locinfo();
else
diff --git a/dlls/msvcrt/wcs.c b/dlls/msvcrt/wcs.c
index bb720e7..9ee4a3b 100644
--- a/dlls/msvcrt/wcs.c
+++ b/dlls/msvcrt/wcs.c
@@ -525,7 +525,7 @@ int CDECL MSVCRT_vsnprintf( char *str, MSVCRT_size_t len,
ret = pf_printf_a(puts_clbk_str_a, &ctx, format, NULL, FALSE, FALSE,
arg_clbk_valist, NULL, &valist);
- puts_clbk_str_a(&ctx, 1, &nullbyte);
+ if (ret >= 0) puts_clbk_str_a(&ctx, 1, &nullbyte);
return ret;
}
--
1.7.5.4
More information about the wine-patches
mailing list