From ad275a5585b0ca1804f05c3bd890145f4f31c3e9 Mon Sep 17 00:00:00 2001 From: Dmitry Kislyuk Date: Thu, 5 Mar 2009 00:01:06 -0600 Subject: Properly handle NULL pointer passed in as filename to GetPrivateProfileSection --- dlls/kernel32/profile.c | 11 +++++++++++ dlls/kernel32/tests/profile.c | 1 - 2 files changed, 11 insertions(+), 1 deletions(-) diff --git a/dlls/kernel32/profile.c b/dlls/kernel32/profile.c index 1a25031..927187f 100644 --- a/dlls/kernel32/profile.c +++ b/dlls/kernel32/profile.c @@ -1350,6 +1350,11 @@ INT WINAPI GetPrivateProfileSectionW( LPCWSTR section, LPWSTR buffer, SetLastError(ERROR_INVALID_PARAMETER); return 0; } + if (!filename) + { + SetLastError(ERROR_FILE_NOT_FOUND); + return 0; + } TRACE("(%s, %p, %d, %s)\n", debugstr_w(section), buffer, len, debugstr_w(filename)); @@ -1378,6 +1383,12 @@ INT WINAPI GetPrivateProfileSectionA( LPCSTR section, LPSTR buffer, SetLastError(ERROR_INVALID_PARAMETER); return 0; } + if (!filename) + { + SetLastError(ERROR_FILE_NOT_FOUND); + return 0; + } + bufferW = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR)); RtlCreateUnicodeStringFromAsciiz(§ionW, section); diff --git a/dlls/kernel32/tests/profile.c b/dlls/kernel32/tests/profile.c index 2e5678c..9ce158f 100644 --- a/dlls/kernel32/tests/profile.c +++ b/dlls/kernel32/tests/profile.c @@ -181,7 +181,6 @@ static void test_profile_sections(void) SetLastError(0xdeadbeef); ret = GetPrivateProfileSectionA( "section1", buf, sizeof(buf), NULL ); ok( ret == 0, "expected return size 0, got %d\n", ret ); - todo_wine ok( GetLastError() == ERROR_FILE_NOT_FOUND || broken(GetLastError() == 0xdeadbeef), /* Win9x, WinME */ "expected ERROR_FILE_NOT_FOUND, got %d\n", GetLastError()); -- 1.5.6.3