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

Side by Side Diff: Source/platform/image-encoders/skia/PNGImageEncoder.cpp

Issue 1212333005: Add a bitmap width and height size check to the PNG encoder (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 5 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) 2010, Google Inc. All rights reserved. 2 * Copyright (c) 2010, Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
114 return true; 114 return true;
115 } 115 }
116 116
117 bool PNGImageEncoder::encode(const SkBitmap& bitmap, Vector<unsigned char>* outp ut) 117 bool PNGImageEncoder::encode(const SkBitmap& bitmap, Vector<unsigned char>* outp ut)
118 { 118 {
119 SkAutoLockPixels bitmapLock(bitmap); 119 SkAutoLockPixels bitmapLock(bitmap);
120 120
121 if (bitmap.colorType() != kN32_SkColorType || !bitmap.getPixels()) 121 if (bitmap.colorType() != kN32_SkColorType || !bitmap.getPixels())
122 return false; // Only support 32 bit/pixel skia bitmaps. 122 return false; // Only support 32 bit/pixel skia bitmaps.
123 123
124 if (bitmap.width() <= 0 || bitmap.height() <= 0)
125 return false; // crbug.com/504690
126
124 return encodePixels(IntSize(bitmap.width(), bitmap.height()), static_cast<un signed char*>(bitmap.getPixels()), true, output); 127 return encodePixels(IntSize(bitmap.width(), bitmap.height()), static_cast<un signed char*>(bitmap.getPixels()), true, output);
125 } 128 }
126 129
127 bool PNGImageEncoder::encode(const ImageDataBuffer& imageData, Vector<unsigned c har>* output) 130 bool PNGImageEncoder::encode(const ImageDataBuffer& imageData, Vector<unsigned c har>* output)
128 { 131 {
129 if (!imageData.pixels()) 132 if (!imageData.pixels())
130 return false; 133 return false;
131 134
132 return encodePixels(IntSize(imageData.width(), imageData.height()), imageDat a.pixels(), false, output); 135 return encodePixels(IntSize(imageData.width(), imageData.height()), imageDat a.pixels(), false, output);
133 } 136 }
134 137
135 } // namespace blink 138 } // 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