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

Issue 1643633005: Avoid dereferencing find() without checking for == end() (Closed)

Created:
4 years, 10 months ago by brucedawson
Modified:
4 years, 10 months ago
Reviewers:
DaleCurtis
CC:
chromium-reviews, feature-media-reviews_chromium.org
Base URL:
https://chromium.googlesource.com/chromium/src.git@master
Target Ref:
refs/pending/heads/master
Project:
chromium
Visibility:
Public.

Description

Avoid dereferencing find() without checking for == end() If (due to an unexpected failure) one of the find() calls in audio_video_metadata_extractor_unittest.cc fails (returns end()) then dereferencing it triggers undefined behavior. This makes the results of the test undefined. In most cases the test failure will still be caught but there are no guarantees. This change adds a helper function to simplify using find() in a way that is safe even in the face of unexpected failures. This was discovered while investigating crbug.com/581768. R=dalecurtis@chromium.org Committed: https://crrev.com/a7a346e3e460cd7273a1346f01e8c260b518a5c6 Cr-Commit-Position: refs/heads/master@{#372219}

Patch Set 1 #

Total comments: 2

Patch Set 2 : Completed fix, and CR nit fixes #

Unified diffs Side-by-side diffs Delta from patch set Stats (+33 lines, -28 lines) Patch
M media/base/audio_video_metadata_extractor_unittest.cc View 1 7 chunks +33 lines, -28 lines 0 comments Download

Messages

Total messages: 9 (3 generated)
brucedawson
Can you take a look at this fix? If the pattern looks good then I'll ...
4 years, 10 months ago (2016-01-28 21:53:52 UTC) #1
DaleCurtis
lgtm % nit https://codereview.chromium.org/1643633005/diff/1/media/base/audio_video_metadata_extractor_unittest.cc File media/base/audio_video_metadata_extractor_unittest.cc (right): https://codereview.chromium.org/1643633005/diff/1/media/base/audio_video_metadata_extractor_unittest.cc#newcode68 media/base/audio_video_metadata_extractor_unittest.cc:68: EXPECT_NE(tag_data, tags.end()); I'd just drop this ...
4 years, 10 months ago (2016-01-28 21:54:47 UTC) #2
brucedawson
Finished. The tests pass/fail appropriately, without dereferencing end() https://codereview.chromium.org/1643633005/diff/1/media/base/audio_video_metadata_extractor_unittest.cc File media/base/audio_video_metadata_extractor_unittest.cc (right): https://codereview.chromium.org/1643633005/diff/1/media/base/audio_video_metadata_extractor_unittest.cc#newcode68 media/base/audio_video_metadata_extractor_unittest.cc:68: EXPECT_NE(tag_data, ...
4 years, 10 months ago (2016-01-28 22:17:26 UTC) #3
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/patch-status/1643633005/20001 View timeline at https://chromium-cq-status.appspot.com/patch-timeline/1643633005/20001
4 years, 10 months ago (2016-01-29 00:09:35 UTC) #6
commit-bot: I haz the power
Committed patchset #2 (id:20001)
4 years, 10 months ago (2016-01-29 00:29:40 UTC) #7
commit-bot: I haz the power
4 years, 10 months ago (2016-01-29 00:30:26 UTC) #9
Message was sent while issue was closed.
Patchset 2 (id:??) landed as
https://crrev.com/a7a346e3e460cd7273a1346f01e8c260b518a5c6
Cr-Commit-Position: refs/heads/master@{#372219}

Powered by Google App Engine
This is Rietveld 408576698