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

Issue 2766263002: Refactor PNGImageDecoder's call to setSize (Closed)

Created:
3 years, 9 months ago by scroggo_chromium
Modified:
3 years, 9 months ago
Reviewers:
msarett1, Peter Kasting
CC:
chromium-reviews, blink-reviews, kinuko+watch
Target Ref:
refs/heads/master
Project:
chromium
Visibility:
Public.

Description

Refactor PNGImageDecoder's call to setSize In the existing code, if setSize fails, PNGImageDecoder attempts to dereference the png_structp owned by m_reader. But setSize calls setFailed on failure, deleting m_reader in the process. As it turns out, it is unnecessary to dereference the png_structp in this case anyway. The intent is to call longjmp in order to stop libpng's processing, but this block of code is only executed when this method is called directly by m_reader, so no need to longjmp. This method, headerAvailable, is called for each frame of a PNG, but the setup code (e.g. setSize) only needs to be done once for the entire image. Separate the pieces that only need to be done once from headerAvailable. This makes it more clear that there is no need to longjmp; use a boolean return instead. Now if setSize fails, no part of m_reader will be accessed. Move the extra size check into a new override of setSize, and move the color space setup code to its own method. Add a test image that reports a size that is too big for ImageDecoder::setSize. Attempting to decode the size should fail. BUG=702934 Review-Url: https://codereview.chromium.org/2766263002 Cr-Commit-Position: refs/heads/master@{#459074} Committed: https://chromium.googlesource.com/chromium/src/+/fab1444fe6528ac403acf28945492f001f3d932e

Patch Set 1 #

Total comments: 2

Patch Set 2 : Spell msarett correctly #

Total comments: 2

Patch Set 3 : Single return statement #

Unified diffs Side-by-side diffs Delta from patch set Stats (+37 lines, -27 lines) Patch
A third_party/WebKit/LayoutTests/images/resources/crbug702934.png View Binary file 0 comments Download
M third_party/WebKit/Source/platform/image-decoders/png/PNGImageDecoder.h View 2 chunks +2 lines, -0 lines 0 comments Download
M third_party/WebKit/Source/platform/image-decoders/png/PNGImageDecoder.cpp View 1 2 3 chunks +25 lines, -27 lines 0 comments Download
M third_party/WebKit/Source/platform/image-decoders/png/PNGImageDecoderTest.cpp View 1 chunk +7 lines, -0 lines 0 comments Download
M third_party/WebKit/Source/platform/image-decoders/png/PNGImageReader.cpp View 1 chunk +3 lines, -0 lines 0 comments Download

Depends on Patchset:

Messages

Total messages: 16 (9 generated)
scroggo_chromium
PTAL I've cc'ed you both on the bug this fixes (crbug.com/702934), so I think you ...
3 years, 9 months ago (2017-03-22 17:00:20 UTC) #2
msarett1
lgtm https://codereview.chromium.org/2766263002/diff/1/third_party/WebKit/Source/platform/image-decoders/png/PNGImageDecoder.cpp File third_party/WebKit/Source/platform/image-decoders/png/PNGImageDecoder.cpp (right): https://codereview.chromium.org/2766263002/diff/1/third_party/WebKit/Source/platform/image-decoders/png/PNGImageDecoder.cpp#newcode206 third_party/WebKit/Source/platform/image-decoders/png/PNGImageDecoder.cpp:206: // TODO(msarret): Add GRAY profile support, block CYMK? ...
3 years, 9 months ago (2017-03-22 19:28:06 UTC) #7
scroggo_chromium
https://codereview.chromium.org/2766263002/diff/1/third_party/WebKit/Source/platform/image-decoders/png/PNGImageDecoder.cpp File third_party/WebKit/Source/platform/image-decoders/png/PNGImageDecoder.cpp (right): https://codereview.chromium.org/2766263002/diff/1/third_party/WebKit/Source/platform/image-decoders/png/PNGImageDecoder.cpp#newcode206 third_party/WebKit/Source/platform/image-decoders/png/PNGImageDecoder.cpp:206: // TODO(msarret): Add GRAY profile support, block CYMK? On ...
3 years, 9 months ago (2017-03-22 19:37:18 UTC) #8
Peter Kasting
LGTM https://codereview.chromium.org/2766263002/diff/20001/third_party/WebKit/Source/platform/image-decoders/png/PNGImageDecoder.cpp File third_party/WebKit/Source/platform/image-decoders/png/PNGImageDecoder.cpp (right): https://codereview.chromium.org/2766263002/diff/20001/third_party/WebKit/Source/platform/image-decoders/png/PNGImageDecoder.cpp#newcode218 third_party/WebKit/Source/platform/image-decoders/png/PNGImageDecoder.cpp:218: return ImageDecoder::setSize(width, height); Nit: Or: return (width <= ...
3 years, 9 months ago (2017-03-22 21:59:52 UTC) #9
scroggo_chromium
https://codereview.chromium.org/2766263002/diff/20001/third_party/WebKit/Source/platform/image-decoders/png/PNGImageDecoder.cpp File third_party/WebKit/Source/platform/image-decoders/png/PNGImageDecoder.cpp (right): https://codereview.chromium.org/2766263002/diff/20001/third_party/WebKit/Source/platform/image-decoders/png/PNGImageDecoder.cpp#newcode218 third_party/WebKit/Source/platform/image-decoders/png/PNGImageDecoder.cpp:218: return ImageDecoder::setSize(width, height); On 2017/03/22 21:59:52, Peter Kasting wrote: ...
3 years, 9 months ago (2017-03-23 12:24:41 UTC) #10
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.org/2766263002/40001
3 years, 9 months ago (2017-03-23 12:24:59 UTC) #13
commit-bot: I haz the power
3 years, 9 months ago (2017-03-23 14:18:04 UTC) #16
Message was sent while issue was closed.
Committed patchset #3 (id:40001) as
https://chromium.googlesource.com/chromium/src/+/fab1444fe6528ac403acf2894549...

Powered by Google App Engine
This is Rietveld 408576698