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

Side by Side Diff: Source/platform/graphics/BitmapImageTest.cpp

Issue 535823002: Don't crash when an image fails to decode. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Rebase Created 6 years, 2 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 | « Source/platform/graphics/BitmapImage.cpp ('k') | 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) 2013, Google Inc. All rights reserved. 2 * Copyright (c) 2013, 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 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
99 for (size_t i = 0; i < decodedFramesCount(); ++i) 99 for (size_t i = 0; i < decodedFramesCount(); ++i)
100 size += frameDecodedSize(i); 100 size += frameDecodedSize(i);
101 return size; 101 return size;
102 } 102 }
103 103
104 void advanceAnimation() 104 void advanceAnimation()
105 { 105 {
106 m_image->advanceAnimation(0); 106 m_image->advanceAnimation(0);
107 } 107 }
108 108
109 PassRefPtr<Image> imageForDefaultFrame()
110 {
111 return m_image->imageForDefaultFrame();
112 }
113
109 protected: 114 protected:
110 virtual void SetUp() OVERRIDE 115 virtual void SetUp() OVERRIDE
111 { 116 {
112 DeferredImageDecoder::setEnabled(false); 117 DeferredImageDecoder::setEnabled(false);
113 m_image = BitmapImage::create(&m_imageObserver); 118 m_image = BitmapImage::create(&m_imageObserver);
114 } 119 }
115 120
116 FakeImageObserver m_imageObserver; 121 FakeImageObserver m_imageObserver;
117 RefPtr<BitmapImage> m_image; 122 RefPtr<BitmapImage> m_image;
118 }; 123 };
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
223 228
224 destroyDecodedData(true); 229 destroyDecodedData(true);
225 resetDecoder(); 230 resetDecoder();
226 231
227 loadImage("/LayoutTests/fast/images/resources/test.webp"); 232 loadImage("/LayoutTests/fast/images/resources/test.webp");
228 EXPECT_EQ(1u, decodedFramesCount()); 233 EXPECT_EQ(1u, decodedFramesCount());
229 EXPECT_EQ(65536u, decodedSize()); 234 EXPECT_EQ(65536u, decodedSize());
230 EXPECT_FALSE(m_image->hasColorProfile()); 235 EXPECT_FALSE(m_image->hasColorProfile());
231 } 236 }
232 237
238 TEST_F(BitmapImageTest, icoHasWrongFrameDimensions)
239 {
240 loadImage("/LayoutTests/fast/images/resources/wrong-frame-dimensions.ico");
241 // This call would cause crash without fix for 408026
242 imageForDefaultFrame();
243 }
244
233 #endif // USE(QCMSLIB) 245 #endif // USE(QCMSLIB)
234 246
235 } // namespace blink 247 } // namespace blink
OLDNEW
« no previous file with comments | « Source/platform/graphics/BitmapImage.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698