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

Issue 2724153004: Declare a variable before using it (Closed)

Created:
3 years, 9 months ago by chengx
Modified:
3 years, 9 months ago
CC:
chromium-reviews, rouslan+autofill_chromium.org, rogerm+autofillwatch_chromium.org, sebsg+autofillwatch_chromium.org, browser-components-watch_chromium.org, mathp+autofillwatch_chromium.org, piman+watch_chromium.org, vabr+watchlistautofill_chromium.org, estade+watch_chromium.org
Target Ref:
refs/pending/heads/master
Project:
chromium
Visibility:
Public.

Description

Declare a variable before using it PVS-Studio pointed out that an uninitialized variable 'limit' is used to initialize itself, which may cause undefined behavior. Other calls to StringToSizeT() don't have this issue. BUG=697659 Review-Url: https://codereview.chromium.org/2724153004 Cr-Commit-Position: refs/heads/master@{#454604} Committed: https://chromium.googlesource.com/chromium/src/+/15343248cec70d6da70eafc4cb87c1626d040349

Patch Set 1 #

Total comments: 3
Unified diffs Side-by-side diffs Delta from patch set Stats (+3 lines, -1 line) Patch
M components/autofill/core/browser/personal_data_manager.cc View 1 chunk +3 lines, -1 line 3 comments Download

Messages

Total messages: 33 (21 generated)
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/2724153004/20001
3 years, 9 months ago (2017-03-02 23:18:21 UTC) #10
commit-bot: I haz the power
No L-G-T-M from a valid reviewer yet. CQ run can only be started by full ...
3 years, 9 months ago (2017-03-02 23:18:23 UTC) #12
chengx
PTAL~
3 years, 9 months ago (2017-03-03 00:12:03 UTC) #14
jbauman
On 2017/03/03 00:12:03, chengx wrote: > PTAL~ I'm not an owner of this file.
3 years, 9 months ago (2017-03-03 00:18:30 UTC) #15
chengx
PTAL~
3 years, 9 months ago (2017-03-03 00:40:52 UTC) #20
Mathieu
lgtm
3 years, 9 months ago (2017-03-03 16:32:29 UTC) #24
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/2724153004/40001
3 years, 9 months ago (2017-03-03 17:10:38 UTC) #26
commit-bot: I haz the power
Committed patchset #1 (id:40001) as https://chromium.googlesource.com/chromium/src/+/15343248cec70d6da70eafc4cb87c1626d040349
3 years, 9 months ago (2017-03-03 17:15:53 UTC) #29
vabr (Chromium)
I'm afraid I have a post-landing not LGTM. Could you please do a follow-up to ...
3 years, 9 months ago (2017-03-04 19:40:29 UTC) #30
chengx
https://codereview.chromium.org/2724153004/diff/40001/components/autofill/core/browser/personal_data_manager.cc File components/autofill/core/browser/personal_data_manager.cc (right): https://codereview.chromium.org/2724153004/diff/40001/components/autofill/core/browser/personal_data_manager.cc#newcode883 components/autofill/core/browser/personal_data_manager.cc:883: size_t limit; On 2017/03/04 19:40:29, vabr (Chromium) wrote: > ...
3 years, 9 months ago (2017-03-06 18:26:14 UTC) #31
vabr (Chromium)
https://codereview.chromium.org/2724153004/diff/40001/components/autofill/core/browser/personal_data_manager.cc File components/autofill/core/browser/personal_data_manager.cc (right): https://codereview.chromium.org/2724153004/diff/40001/components/autofill/core/browser/personal_data_manager.cc#newcode883 components/autofill/core/browser/personal_data_manager.cc:883: size_t limit; On 2017/03/06 18:26:14, chengx wrote: > On ...
3 years, 9 months ago (2017-03-06 18:46:48 UTC) #32
vabr (Chromium)
3 years, 9 months ago (2017-03-06 19:51:04 UTC) #33
Message was sent while issue was closed.
On 2017/03/06 18:46:48, vabr (Chromium) wrote:
>
https://codereview.chromium.org/2724153004/diff/40001/components/autofill/cor...
> File components/autofill/core/browser/personal_data_manager.cc (right):
> 
>
https://codereview.chromium.org/2724153004/diff/40001/components/autofill/cor...
> components/autofill/core/browser/personal_data_manager.cc:883: size_t limit;
> On 2017/03/06 18:26:14, chengx wrote:
> > On 2017/03/04 19:40:29, vabr (Chromium) wrote:
> > > This is actually worse than before. Before there was not a single point in
> the
> > > code where |limit| would not be initialised. Now the declaration and
> > assignment
> > > are separate, and if somebody adds code between them, there will be a
> > > non-trivial interval of |limit| having an undefined value.
> > > 
> > > Please either revert to the previous state, or initialize limit. A good
> > default
> > > value is SIZE_MAX. Note that you also still need to keep the assignment
> after
> > > calling StringToSizeT, because that method can modify |limit| even if it
> > returns
> > > false. This would be good to capture in a comment here as well.
> > > 
> > > size_t limit = SIZE_MAX;
> > 
> > I will use another CL to fix this. Thanks!
> 
> SGTM, thanks for following up! :)

LGTM because of the follow-up in https://codereview.chromium.org/2732913004/.

Powered by Google App Engine
This is Rietveld 408576698