Commit 9e840993 authored by sky@chromium.org's avatar sky@chromium.org

Fixes possible crash in CursorHeightProvider

Crash data seems to indicate GetSystemMetrics(SM_CYCURSOR) can return
a value bigger than the bitmap height. Go figure.

BUG=378848
TEST=none
R=ananta@chromium.org

Review URL: https://codereview.chromium.org/311463002

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@274001 0039d316-1c4b-4281-b951-d872f2087c98
parent 13ccdbe1
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
#include "ui/views/corewm/cursor_height_provider_win.h" #include "ui/views/corewm/cursor_height_provider_win.h"
#include <windows.h> #include <windows.h>
#include <algorithm>
#include <map> #include <map>
#include "base/basictypes.h" #include "base/basictypes.h"
...@@ -105,7 +106,9 @@ int CalculateCursorHeight(HCURSOR cursor_handle) { ...@@ -105,7 +106,9 @@ int CalculateCursorHeight(HCURSOR cursor_handle) {
return kDefaultHeight; return kDefaultHeight;
const int cursor_height = GetSystemMetrics(SM_CYCURSOR); const int cursor_height = GetSystemMetrics(SM_CYCURSOR);
int i = bitmap_info.bmiHeader.biHeight - cursor_height; // Crash data seems to indicate cursor_height may be bigger than the bitmap.
int i = std::max(0, static_cast<int>(bitmap_info.bmiHeader.biHeight) -
cursor_height);
for (; i < bitmap_info.bmiHeader.biHeight; ++i) { for (; i < bitmap_info.bmiHeader.biHeight; ++i) {
if (!IsRowTransparent(data, row_size, last_byte_mask, i)) { if (!IsRowTransparent(data, row_size, last_byte_mask, i)) {
i--; i--;
......
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