Fix Visual Studio Code Analysis warning C6011: Dereferencing NULL pointer 'returnedDevmode'

svn path=/trunk/; revision=54051
This commit is contained in:
Chris Maynard 2013-12-13 18:25:06 +00:00
parent 4cabb63481
commit 093ace5c24
1 changed files with 8 additions and 0 deletions

View File

@ -130,6 +130,14 @@ static HDC get_printer_dc(short *width, short *height)
/* http://msdn.microsoft.com/en-us/library/windows/desktop/dd162931%28v=vs.85%29.aspx */
returnedDevmode = (PDEVMODE)GlobalLock(pdlg.hDevMode);
if (returnedDevmode == NULL) {
if (pdlg.hDevMode)
GlobalFree(pdlg.hDevMode);
if (pdlg.hDevNames)
GlobalFree(pdlg.hDevNames);
return NULL;
}
if (returnedDevmode->dmOrientation == DMORIENT_LANDSCAPE) {
*width = returnedDevmode->dmPaperLength;
*height = returnedDevmode->dmPaperWidth;