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

Side by Side Diff: third_party/WebKit/Source/core/html/HTMLCanvasElement.cpp

Issue 2170693003: Fix integer over flow issue in HTMLCanvasElement::canCreateImageBuffer (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: use CheckedNumeric Created 4 years, 5 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 unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2004, 2006, 2007 Apple Inc. All rights reserved. 2 * Copyright (C) 2004, 2006, 2007 Apple Inc. All rights reserved.
3 * Copyright (C) 2007 Alp Toker <alp@atoker.com> 3 * Copyright (C) 2007 Alp Toker <alp@atoker.com>
4 * Copyright (C) 2010 Torch Mobile (Beijing) Co. Ltd. All rights reserved. 4 * Copyright (C) 2010 Torch Mobile (Beijing) Co. Ltd. All rights reserved.
5 * 5 *
6 * Redistribution and use in source and binary forms, with or without 6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions 7 * modification, are permitted provided that the following conditions
8 * are met: 8 * are met:
9 * 1. Redistributions of source code must retain the above copyright 9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer. 10 * notice, this list of conditions and the following disclaimer.
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
115 // misinterpreted as a user-input value 115 // misinterpreted as a user-input value
116 const int UndefinedQualityValue = -1.0; 116 const int UndefinedQualityValue = -1.0;
117 117
118 // Default image mime type for toDataURL and toBlob functions 118 // Default image mime type for toDataURL and toBlob functions
119 const char DefaultMimeType[] = "image/png"; 119 const char DefaultMimeType[] = "image/png";
120 120
121 bool canCreateImageBuffer(const IntSize& size) 121 bool canCreateImageBuffer(const IntSize& size)
122 { 122 {
123 if (size.isEmpty()) 123 if (size.isEmpty())
124 return false; 124 return false;
125 if (size.width() * size.height() > MaxCanvasArea) 125 CheckedNumeric<int> area = size.width();
126 area *= size.height();
127 if (!area.IsValid() || area.ValueOrDie() > MaxCanvasArea)
126 return false; 128 return false;
127 if (size.width() > MaxSkiaDim || size.height() > MaxSkiaDim) 129 if (size.width() > MaxSkiaDim || size.height() > MaxSkiaDim)
128 return false; 130 return false;
129 return true; 131 return true;
130 } 132 }
131 133
132 PassRefPtr<Image> createTransparentImage(const IntSize& size) 134 PassRefPtr<Image> createTransparentImage(const IntSize& size)
133 { 135 {
134 DCHECK(canCreateImageBuffer(size)); 136 DCHECK(canCreateImageBuffer(size));
135 sk_sp<SkSurface> surface = SkSurface::MakeRasterN32Premul(size.width(), size .height()); 137 sk_sp<SkSurface> surface = SkSurface::MakeRasterN32Premul(size.width(), size .height());
(...skipping 1088 matching lines...) Expand 10 before | Expand all | Expand 10 after
1224 1226
1225 bool HTMLCanvasElement::createSurfaceLayer() 1227 bool HTMLCanvasElement::createSurfaceLayer()
1226 { 1228 {
1227 DCHECK(!m_surfaceLayerBridge); 1229 DCHECK(!m_surfaceLayerBridge);
1228 std::unique_ptr<CanvasSurfaceLayerBridgeClient> bridgeClient = wrapUnique(ne w CanvasSurfaceLayerBridgeClientImpl()); 1230 std::unique_ptr<CanvasSurfaceLayerBridgeClient> bridgeClient = wrapUnique(ne w CanvasSurfaceLayerBridgeClientImpl());
1229 m_surfaceLayerBridge = wrapUnique(new CanvasSurfaceLayerBridge(std::move(bri dgeClient))); 1231 m_surfaceLayerBridge = wrapUnique(new CanvasSurfaceLayerBridge(std::move(bri dgeClient)));
1230 return m_surfaceLayerBridge->createSurfaceLayer(this->width(), this->height( )); 1232 return m_surfaceLayerBridge->createSurfaceLayer(this->width(), this->height( ));
1231 } 1233 }
1232 1234
1233 } // namespace blink 1235 } // namespace blink
OLDNEW
« 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