Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(466)

Unified Diff: ui/views/corewm/cursor_height_provider_win.cc

Issue 311463002: Fixes possible crash in CursorHeightProvider (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: include and cast Created 6 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/views/corewm/cursor_height_provider_win.cc
diff --git a/ui/views/corewm/cursor_height_provider_win.cc b/ui/views/corewm/cursor_height_provider_win.cc
index e0f79e69371698a3863c96c7becb3ba5f6922a7f..97ed7a3465e5ab6fac56d1a4497c8d01e7fabb5b 100644
--- a/ui/views/corewm/cursor_height_provider_win.cc
+++ b/ui/views/corewm/cursor_height_provider_win.cc
@@ -5,6 +5,7 @@
#include "ui/views/corewm/cursor_height_provider_win.h"
#include <windows.h>
+#include <algorithm>
#include <map>
#include "base/basictypes.h"
@@ -105,7 +106,9 @@ int CalculateCursorHeight(HCURSOR cursor_handle) {
return kDefaultHeight;
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) {
if (!IsRowTransparent(data, row_size, last_byte_mask, i)) {
i--;
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698