Commit 4a431afd authored by Paul Vriens's avatar Paul Vriens Committed by Alexandre Julliard

kernel32/profile: Add a few NULL checks (Coverity).

parent 0230695a
...@@ -1324,6 +1324,12 @@ INT WINAPI GetPrivateProfileSectionW( LPCWSTR section, LPWSTR buffer, ...@@ -1324,6 +1324,12 @@ INT WINAPI GetPrivateProfileSectionW( LPCWSTR section, LPWSTR buffer,
{ {
int ret = 0; int ret = 0;
if (!section || !buffer)
{
SetLastError(ERROR_INVALID_PARAMETER);
return 0;
}
TRACE("(%s, %p, %d, %s)\n", debugstr_w(section), buffer, len, debugstr_w(filename)); TRACE("(%s, %p, %d, %s)\n", debugstr_w(section), buffer, len, debugstr_w(filename));
RtlEnterCriticalSection( &PROFILE_CritSect ); RtlEnterCriticalSection( &PROFILE_CritSect );
...@@ -1346,9 +1352,14 @@ INT WINAPI GetPrivateProfileSectionA( LPCSTR section, LPSTR buffer, ...@@ -1346,9 +1352,14 @@ INT WINAPI GetPrivateProfileSectionA( LPCSTR section, LPSTR buffer,
LPWSTR bufferW; LPWSTR bufferW;
INT retW, ret = 0; INT retW, ret = 0;
bufferW = buffer ? HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR)) : NULL; if (!section || !buffer)
if (section) RtlCreateUnicodeStringFromAsciiz(&sectionW, section); {
else sectionW.Buffer = NULL; SetLastError(ERROR_INVALID_PARAMETER);
return 0;
}
bufferW = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR));
RtlCreateUnicodeStringFromAsciiz(&sectionW, section);
if (filename) RtlCreateUnicodeStringFromAsciiz(&filenameW, filename); if (filename) RtlCreateUnicodeStringFromAsciiz(&filenameW, filename);
else filenameW.Buffer = NULL; else filenameW.Buffer = NULL;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment