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

Issue 618503002: Fix the open file dialog on Windows (Closed)

Created:
6 years, 2 months ago by luken
Modified:
6 years, 2 months ago
Base URL:
https://chromium.googlesource.com/chromium/src.git@master
Project:
chromium
Visibility:
Public.

Description

Fix the open file dialog on Windows Currently even if a valid file is selected the OpenFileDialog is likely to return an emtpy FilePath, depending on what is in memory after the sole string returned by the Windows OFD. The code as written assumes the Windows OFD will always return a null-terminated list of null-terminated strings when returning successfully from the call to the OFD. However if you check the MSDN documentation at: http://msdn.microsoft.com/en-us/library/windows/desktop/ms646839(v=vs.85).aspx You will find this is not the case, and the return value depends on the presence of OFN_ALLOWMULTISELECT in the Flags argument. If that value is not set, which it is not in the case of single-file selection, then there is only a single string in |openfilename_.lpstrFile|, and the code within OpenFileName::GetResult() blows past that single NULL and into unitialized memory, which ::GetSingleResult then assumes means an invalid return filename and returns the empty FilePath. This CL repairs that situation so that GetSingleResult now DCHECKS that the OFN_ALLOWMULTISELECT is not there and returns the string directly, and ::GetResult() asserts that the flag is present and continues to do its multi-value parsing that it was doing before. BUG=418760 TEST=Launch Chrome, hit CTRL+O to open a file, chose a valid test html file, observe that the browser doesn't crash and successfully opens that file. Committed: https://crrev.com/702fdfed602988a1d404ae4c862c252d40209995 Cr-Commit-Position: refs/heads/master@{#297489}

Patch Set 1 #

Total comments: 4

Patch Set 2 : fixing unit tests and feedback #

Unified diffs Side-by-side diffs Delta from patch set Stats (+28 lines, -6 lines) Patch
M ui/base/win/open_file_name_win.cc View 1 1 chunk +12 lines, -3 lines 0 comments Download
M ui/base/win/open_file_name_win_unittest.cc View 1 2 chunks +16 lines, -3 lines 0 comments Download

Messages

Total messages: 12 (3 generated)
luken
6 years, 2 months ago (2014-09-29 23:11:13 UTC) #2
sky
https://codereview.chromium.org/618503002/diff/1/ui/base/win/open_file_name_win.cc File ui/base/win/open_file_name_win.cc (right): https://codereview.chromium.org/618503002/diff/1/ui/base/win/open_file_name_win.cc#newcode141 ui/base/win/open_file_name_win.cc:141: base::FilePath OpenFileName::GetSingleResult() { I would rather we always do ...
6 years, 2 months ago (2014-09-29 23:53:03 UTC) #4
erikwright (departed)
On 2014/09/29 23:53:03, sky wrote: > https://codereview.chromium.org/618503002/diff/1/ui/base/win/open_file_name_win.cc > File ui/base/win/open_file_name_win.cc (right): > > https://codereview.chromium.org/618503002/diff/1/ui/base/win/open_file_name_win.cc#newcode141 > ...
6 years, 2 months ago (2014-09-30 00:14:13 UTC) #5
luken
I repaired the two unit tests that were not setting OFN_MULTISELECT but were providing test ...
6 years, 2 months ago (2014-09-30 17:25:07 UTC) #6
erikwright (departed)
LGTM. Thank you for digging into and fixing this!
6 years, 2 months ago (2014-09-30 17:34:15 UTC) #7
sky
LGTM
6 years, 2 months ago (2014-09-30 19:19:28 UTC) #8
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/patch-status/618503002/20001
6 years, 2 months ago (2014-09-30 19:22:14 UTC) #10
commit-bot: I haz the power
Committed patchset #2 (id:20001) as c690c791cdf65683d52ba49902a66e9327188b58
6 years, 2 months ago (2014-09-30 20:15:32 UTC) #11
commit-bot: I haz the power
6 years, 2 months ago (2014-09-30 20:16:10 UTC) #12
Message was sent while issue was closed.
Patchset 2 (id:??) landed as
https://crrev.com/702fdfed602988a1d404ae4c862c252d40209995
Cr-Commit-Position: refs/heads/master@{#297489}

Powered by Google App Engine
This is Rietveld 408576698