diff --git a/dlls/imagehlp/integrity.c b/dlls/imagehlp/integrity.c index df6de0fe366..bbec56b1a81 100644 --- a/dlls/imagehlp/integrity.c +++ b/dlls/imagehlp/integrity.c @@ -226,15 +226,15 @@ BOOL WINAPI ImageGetCertificateData( TRACE("%p %d %p %p\n", handle, Index, Certificate, RequiredLength); + if( !RequiredLength) + { + SetLastError( ERROR_INVALID_PARAMETER ); + return FALSE; + } + if( !IMAGEHLP_GetCertificateOffset( handle, Index, &ofs, &size ) ) return FALSE; - if( !Certificate ) - { - *RequiredLength = size; - return TRUE; - } - if( *RequiredLength < size ) { *RequiredLength = size; @@ -242,6 +242,12 @@ BOOL WINAPI ImageGetCertificateData( return FALSE; } + if( !Certificate ) + { + SetLastError( ERROR_INVALID_PARAMETER ); + return FALSE; + } + *RequiredLength = size; offset = SetFilePointer( handle, ofs, NULL, FILE_BEGIN ); @@ -255,6 +261,7 @@ BOOL WINAPI ImageGetCertificateData( return FALSE; TRACE("OK\n"); + SetLastError( NO_ERROR ); return TRUE; }