Chromium Code Reviews| Index: webkit/glue/webcursor_mac.mm |
| diff --git a/webkit/glue/webcursor_mac.mm b/webkit/glue/webcursor_mac.mm |
| index 8c72da206af47101416ae2c25435e43203485bcd..ca9ee0d0b52e70103f1b007cdd787cfdc5e20662 100644 |
| --- a/webkit/glue/webcursor_mac.mm |
| +++ b/webkit/glue/webcursor_mac.mm |
| @@ -40,7 +40,9 @@ CGImageRef CreateCGImageFromCustomData(const std::vector<char>& custom_data, |
| base::mac::ScopedCFTypeRef<CGColorSpaceRef> cg_color( |
| CGColorSpaceCreateDeviceRGB()); |
| // This is safe since we're not going to draw into the context we're creating. |
| - void* data = const_cast<char*>(&custom_data[0]); |
| + void* data = NULL; |
| + if (!custom_data.empty()) |
| + data = const_cast<char*>(&custom_data[0]); |
| // The settings here match SetCustomData() below; keep in sync. |
| base::mac::ScopedCFTypeRef<CGContextRef> context( |
| CGBitmapContextCreate(data, |
|
Avi (use Gerrit)
2011/06/29 00:22:47
You can do that, pass in a null data for a 0x0 ima
Scott Hess - ex-Googler
2011/06/29 01:06:13
Docs say that passing NULL means that Quartz alloc
|
| @@ -57,10 +59,6 @@ CGImageRef CreateCGImageFromCustomData(const std::vector<char>& custom_data, |
| NSCursor* CreateCustomCursor(const std::vector<char>& custom_data, |
| const gfx::Size& custom_size, |
| const gfx::Point& hotspot) { |
| - // CG throws a cocoa exception if we try to create an empty image, which |
| - // results in an infinite loop. This CHECK ensures that we crash instead. |
| - CHECK(!custom_data.empty()); |
| - |
| base::mac::ScopedCFTypeRef<CGImageRef> cg_image( |
| CreateCGImageFromCustomData(custom_data, custom_size)); |