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

Issue 1058873006: Get rid of leaks in SkCodec::NewFromStream. (Closed)

Created:
5 years, 8 months ago by scroggo
Modified:
5 years, 8 months ago
Reviewers:
msarett, mtklein
CC:
reviews_skia.org
Base URL:
https://skia.googlesource.com/skia.git@master
Target Ref:
refs/heads/master
Project:
skia
Visibility:
Public.

Description

Get rid of leaks in SkCodec::NewFromStream. SkCodec::NewFromStream claims to delete the passed in SkStream on failure. This allows the caller to pass an SkStream to the function and not worry about deleting it depending on the return value. Most of our SkCodecs did not honor this contract though. Update them to delete the stream on failure. Further, update SkCodec::NewFromStream to delete the stream if it did not match any subclass, and delete the SkCodec if we decided to return NULL because it was too big. Add a test which tests streams which represent the beginnings of supported format types but do not contain enough data to create an SkCodec. The interesting part of the test is when we run it on ASAN, which will report that we leaked something without the other changes. BUG=skia:3257 Committed: https://skia.googlesource.com/skia/+/0a7e69cb9b4e3929d659891d152a2c0b59bff4e0

Patch Set 1 #

Total comments: 2

Patch Set 2 : Add comment that ReadHeader does not own SkStream. #

Unified diffs Side-by-side diffs Delta from patch set Stats (+48 lines, -8 lines) Patch
M src/codec/SkCodec.cpp View 3 chunks +6 lines, -5 lines 0 comments Download
M src/codec/SkCodec_libbmp.h View 1 1 chunk +1 line, -0 lines 0 comments Download
M src/codec/SkCodec_libbmp.cpp View 1 2 chunks +6 lines, -0 lines 0 comments Download
M src/codec/SkCodec_libgif.cpp View 2 chunks +2 lines, -1 line 0 comments Download
M src/codec/SkCodec_libpng.cpp View 1 chunk +2 lines, -1 line 0 comments Download
M src/codec/SkCodec_wbmp.cpp View 2 chunks +2 lines, -1 line 0 comments Download
M tests/CodexTest.cpp View 1 chunk +29 lines, -0 lines 0 comments Download

Messages

Total messages: 14 (4 generated)
scroggo
5 years, 8 months ago (2015-04-02 21:23:21 UTC) #2
mtklein
An alternative is to change the docs to say "Does not take ownership of the ...
5 years, 8 months ago (2015-04-02 22:11:57 UTC) #3
msarda
On 2015/04/02 22:11:57, mtklein wrote: > An alternative is to change the docs to say ...
5 years, 8 months ago (2015-04-03 08:30:41 UTC) #4
scroggo
On 2015/04/02 22:11:57, mtklein wrote: > An alternative is to change the docs to say ...
5 years, 8 months ago (2015-04-03 13:04:04 UTC) #6
mtklein
Gotcha. Wasn't thinking about deferred. lgtm with one suggestion. https://codereview.chromium.org/1058873006/diff/1/src/codec/SkCodec_libbmp.cpp File src/codec/SkCodec_libbmp.cpp (right): https://codereview.chromium.org/1058873006/diff/1/src/codec/SkCodec_libbmp.cpp#newcode501 src/codec/SkCodec_libbmp.cpp:501: ...
5 years, 8 months ago (2015-04-03 13:13:05 UTC) #7
scroggo
Note: I ran some trybots to check for leaks, and while both runs had exceptions, ...
5 years, 8 months ago (2015-04-03 13:13:50 UTC) #8
scroggo
https://codereview.chromium.org/1058873006/diff/1/src/codec/SkCodec_libbmp.cpp File src/codec/SkCodec_libbmp.cpp (right): https://codereview.chromium.org/1058873006/diff/1/src/codec/SkCodec_libbmp.cpp#newcode501 src/codec/SkCodec_libbmp.cpp:501: if (ReadHeader(stream, isIco, &codec)) { On 2015/04/03 13:13:05, mtklein ...
5 years, 8 months ago (2015-04-03 13:59:53 UTC) #9
mtklein
On 2015/04/03 13:59:53, scroggo wrote: > https://codereview.chromium.org/1058873006/diff/1/src/codec/SkCodec_libbmp.cpp > File src/codec/SkCodec_libbmp.cpp (right): > > https://codereview.chromium.org/1058873006/diff/1/src/codec/SkCodec_libbmp.cpp#newcode501 > ...
5 years, 8 months ago (2015-04-03 14:01:28 UTC) #10
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/patch-status/1058873006/10007
5 years, 8 months ago (2015-04-03 14:10:28 UTC) #13
commit-bot: I haz the power
5 years, 8 months ago (2015-04-03 14:22:25 UTC) #14
Message was sent while issue was closed.
Committed patchset #2 (id:10007) as
https://skia.googlesource.com/skia/+/0a7e69cb9b4e3929d659891d152a2c0b59bff4e0

Powered by Google App Engine
This is Rietveld 408576698