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

Side by Side Diff: src/images/SkImageDecoder_libwebp.cpp

Issue 122293002: Revert "Revert of https://codereview.chromium.org/113823003/" (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Created 6 years, 11 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 | Annotate | Revision Log
« no previous file with comments | « src/images/SkImageDecoder_libpng.cpp ('k') | tests/BitmapCopyTest.cpp » ('j') | 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 2010, The Android Open Source Project 2 * Copyright 2010, The Android Open Source Project
3 * 3 *
4 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License. 5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at 6 * You may obtain a copy of the License at
7 * 7 *
8 * http://www.apache.org/licenses/LICENSE-2.0 8 * http://www.apache.org/licenses/LICENSE-2.0
9 * 9 *
10 * Unless required by applicable law or agreed to in writing, software 10 * Unless required by applicable law or agreed to in writing, software
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
73 VP8StatusCode status = WebPGetFeatures(buffer, totalBytesRead, &features); 73 VP8StatusCode status = WebPGetFeatures(buffer, totalBytesRead, &features);
74 if (VP8_STATUS_OK != status) { 74 if (VP8_STATUS_OK != status) {
75 return false; // Invalid WebP file. 75 return false; // Invalid WebP file.
76 } 76 }
77 *width = features.width; 77 *width = features.width;
78 *height = features.height; 78 *height = features.height;
79 *alpha = features.has_alpha; 79 *alpha = features.has_alpha;
80 80
81 // sanity check for image size that's about to be decoded. 81 // sanity check for image size that's about to be decoded.
82 { 82 {
83 Sk64 size; 83 int64_t size = sk_64_mul(*width, *height);
84 size.setMul(*width, *height); 84 if (!sk_64_isS32(size)) {
85 if (size.isNeg() || !size.is32()) {
86 return false; 85 return false;
87 } 86 }
88 // now check that if we are 4-bytes per pixel, we also don't overflow 87 // now check that if we are 4-bytes per pixel, we also don't overflow
89 if (size.get32() > (0x7FFFFFFF >> 2)) { 88 if (sk_64_asS32(size) > (0x7FFFFFFF >> 2)) {
90 return false; 89 return false;
91 } 90 }
92 } 91 }
93 return true; 92 return true;
94 } 93 }
95 94
96 class SkWEBPImageDecoder: public SkImageDecoder { 95 class SkWEBPImageDecoder: public SkImageDecoder {
97 public: 96 public:
98 SkWEBPImageDecoder() { 97 SkWEBPImageDecoder() {
99 fInputStream = NULL; 98 fInputStream = NULL;
(...skipping 496 matching lines...) Expand 10 before | Expand all | Expand 10 after
596 return SkImageDecoder::kUnknown_Format; 595 return SkImageDecoder::kUnknown_Format;
597 } 596 }
598 597
599 static SkImageEncoder* sk_libwebp_efactory(SkImageEncoder::Type t) { 598 static SkImageEncoder* sk_libwebp_efactory(SkImageEncoder::Type t) {
600 return (SkImageEncoder::kWEBP_Type == t) ? SkNEW(SkWEBPImageEncoder) : NUL L; 599 return (SkImageEncoder::kWEBP_Type == t) ? SkNEW(SkWEBPImageEncoder) : NUL L;
601 } 600 }
602 601
603 static SkImageDecoder_DecodeReg gDReg(sk_libwebp_dfactory); 602 static SkImageDecoder_DecodeReg gDReg(sk_libwebp_dfactory);
604 static SkImageDecoder_FormatReg gFormatReg(get_format_webp); 603 static SkImageDecoder_FormatReg gFormatReg(get_format_webp);
605 static SkImageEncoder_EncodeReg gEReg(sk_libwebp_efactory); 604 static SkImageEncoder_EncodeReg gEReg(sk_libwebp_efactory);
OLDNEW
« no previous file with comments | « src/images/SkImageDecoder_libpng.cpp ('k') | tests/BitmapCopyTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698