Module: wine Branch: master Commit: 29de7dd60ba27c7aa79f455b4f4bc9c56c8292d0 URL: http://source.winehq.org/git/wine.git/?a=commit;h=29de7dd60ba27c7aa79f455b4f...
Author: Sebastian Lackner sebastian@fds-team.de Date: Fri Dec 20 05:55:34 2013 +0100
ntdll: Handle error if RtlAllocateHeap fails in printf functions.
---
dlls/ntdll/printf.c | 14 +++++++++++--- 1 files changed, 11 insertions(+), 3 deletions(-)
diff --git a/dlls/ntdll/printf.c b/dlls/ntdll/printf.c index 49d3983..3a5067a 100644 --- a/dlls/ntdll/printf.c +++ b/dlls/ntdll/printf.c @@ -300,7 +300,13 @@ static void pf_integer_conv( char *buf, int buf_len, pf_flags *flags, char number[40], *tmp = number;
if( buf_len > sizeof number ) - tmp = RtlAllocateHeap( GetProcessHeap(), 0, buf_len ); + { + if (!(tmp = RtlAllocateHeap( GetProcessHeap(), 0, buf_len ))) + { + buf[0] = '\0'; + return; + } + }
base = 10; if( flags->Format == 'o' ) @@ -588,7 +594,8 @@ static int pf_vsnprintf( pf_output *out, const WCHAR *format, __ms_va_list valis flags.FieldLength : flags.Precision) + 10;
if( x_len >= sizeof number) - x = RtlAllocateHeap( GetProcessHeap(), 0, x_len ); + if (!(x = RtlAllocateHeap( GetProcessHeap(), 0, x_len ))) + return -1;
pf_integer_conv( x, x_len, &flags, va_arg(valist, LONGLONG) );
@@ -611,7 +618,8 @@ static int pf_vsnprintf( pf_output *out, const WCHAR *format, __ms_va_list valis flags.FieldLength : flags.Precision) + 10;
if( x_len >= sizeof number) - x = RtlAllocateHeap( GetProcessHeap(), 0, x_len ); + if (!(x = RtlAllocateHeap( GetProcessHeap(), 0, x_len ))) + return -1;
pf_rebuild_format_string( fmt, &flags );