summaryrefslogtreecommitdiffstats
path: root/chrome/browser
diff options
context:
space:
mode:
authorbeng@google.com <beng@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2008-09-07 18:45:26 +0000
committerbeng@google.com <beng@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2008-09-07 18:45:26 +0000
commit62eb8e3e7347765f88e28c2cbc7e7b9223ca13a4 (patch)
treecc4022c66148374716e214722ddeee8ea3d0e6c6 /chrome/browser
parentf37e85112f6e1ce670bc50963f79b392c6af30bb (diff)
downloadchromium_src-62eb8e3e7347765f88e28c2cbc7e7b9223ca13a4.zip
chromium_src-62eb8e3e7347765f88e28c2cbc7e7b9223ca13a4.tar.gz
chromium_src-62eb8e3e7347765f88e28c2cbc7e7b9223ca13a4.tar.bz2
Don't reinvent the wheel - base::wclscpy does this work in one line of code.
Review URL: http://codereview.chromium.org/1807 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@1828 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser')
-rw-r--r--chrome/browser/views/shell_dialogs.cc8
1 files changed, 2 insertions, 6 deletions
diff --git a/chrome/browser/views/shell_dialogs.cc b/chrome/browser/views/shell_dialogs.cc
index 483e223..7e41937 100644
--- a/chrome/browser/views/shell_dialogs.cc
+++ b/chrome/browser/views/shell_dialogs.cc
@@ -13,6 +13,7 @@
#include "base/file_util.h"
#include "base/registry.h"
+#include "base/string_util.h"
#include "base/thread.h"
#include "chrome/browser/browser_process.h"
#include "chrome/common/gfx/chrome_font.h"
@@ -340,13 +341,8 @@ bool SelectFileDialogImpl::RunOpenFileDialog(const std::wstring& title,
ofn.lStructSize = sizeof(ofn);
ofn.hwndOwner = owner;
- // This will clamp the number of characters copied from the supplied path
- // to the value of MAX_PATH.
- size_t name_size = std::min(path->length() + 1,
- static_cast<size_t>(MAX_PATH));
wchar_t filename[MAX_PATH];
- memcpy(filename, path->c_str(), name_size * sizeof(wchar_t));
- filename[MAX_PATH - 1] = '\0';
+ base::wcslcpy(filename, path->c_str(), arraysize(filename));
ofn.lpstrFile = filename;
ofn.nMaxFile = MAX_PATH;