mirror of
https://github.com/reactos/reactos.git
synced 2024-05-15 17:51:58 +00:00
[WIN32SS] Don't trigger ProbeForWrite when retrieving caret size from co_IntDrawCaret, fix unlocking in failure path. CORE-10308
svn path=/trunk/; revision=73517
This commit is contained in:
parent
657d78a387
commit
e8801e23b6
|
@ -430,13 +430,12 @@ NtGdiCreateCompatibleBitmap(
|
|||
}
|
||||
|
||||
BOOL
|
||||
APIENTRY
|
||||
NtGdiGetBitmapDimension(
|
||||
HBITMAP hBitmap,
|
||||
LPSIZE psizDim)
|
||||
NTAPI
|
||||
GreGetBitmapDimension(
|
||||
_In_ HBITMAP hBitmap,
|
||||
_Out_ LPSIZE psizDim)
|
||||
{
|
||||
PSURFACE psurfBmp;
|
||||
BOOL bResult = TRUE;
|
||||
|
||||
if (hBitmap == NULL)
|
||||
return FALSE;
|
||||
|
@ -449,22 +448,38 @@ NtGdiGetBitmapDimension(
|
|||
return FALSE;
|
||||
}
|
||||
|
||||
/* Use SEH to copy the data to the caller */
|
||||
_SEH2_TRY
|
||||
{
|
||||
ProbeForWrite(psizDim, sizeof(SIZE), 1);
|
||||
*psizDim = psurfBmp->sizlDim;
|
||||
}
|
||||
_SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
|
||||
{
|
||||
bResult = FALSE;
|
||||
}
|
||||
_SEH2_END
|
||||
*psizDim = psurfBmp->sizlDim;
|
||||
|
||||
/* Unlock the bitmap */
|
||||
SURFACE_ShareUnlockSurface(psurfBmp);
|
||||
|
||||
return bResult;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
BOOL
|
||||
APIENTRY
|
||||
NtGdiGetBitmapDimension(
|
||||
HBITMAP hBitmap,
|
||||
LPSIZE psizDim)
|
||||
{
|
||||
SIZE dim;
|
||||
|
||||
if (!GreGetBitmapDimension(hBitmap, &dim))
|
||||
return FALSE;
|
||||
|
||||
/* Use SEH to copy the data to the caller */
|
||||
_SEH2_TRY
|
||||
{
|
||||
ProbeForWrite(psizDim, sizeof(*psizDim), 1);
|
||||
*psizDim = dim;
|
||||
}
|
||||
_SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
|
||||
{
|
||||
_SEH2_YIELD(return FALSE);
|
||||
}
|
||||
_SEH2_END
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -50,3 +50,10 @@ UnsafeSetBitmapBits(
|
|||
_Inout_ PSURFACE psurf,
|
||||
_In_ ULONG cjBits,
|
||||
_In_ const VOID *pvBits);
|
||||
|
||||
BOOL
|
||||
NTAPI
|
||||
GreGetBitmapDimension(
|
||||
_In_ HBITMAP hBitmap,
|
||||
_Out_ LPSIZE psizDim);
|
||||
|
||||
|
|
|
@ -43,10 +43,10 @@ co_IntDrawCaret(PWND pWnd, PTHRDCARETINFO CaretInfo)
|
|||
|
||||
if (CaretInfo->Bitmap)
|
||||
{
|
||||
if (!NtGdiGetBitmapDimension(CaretInfo->Bitmap, &CaretInfo->Size))
|
||||
if (!GreGetBitmapDimension(CaretInfo->Bitmap, &CaretInfo->Size))
|
||||
{
|
||||
ERR("Failed to get bitmap dimensions\n");
|
||||
return;
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
hdcMem = NtGdiCreateCompatibleDC(hdc);
|
||||
|
@ -79,6 +79,7 @@ co_IntDrawCaret(PWND pWnd, PTHRDCARETINFO CaretInfo)
|
|||
DSTINVERT);
|
||||
}
|
||||
|
||||
cleanup:
|
||||
if (pWnd->hrgnUpdate)
|
||||
{
|
||||
NtGdiRestoreDC(hdc, -1);
|
||||
|
|
Loading…
Reference in a new issue