summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--media/base/media_win.cc16
1 files changed, 14 insertions, 2 deletions
diff --git a/media/base/media_win.cc b/media/base/media_win.cc
index e4d67f5..b0357f7 100644
--- a/media/base/media_win.cc
+++ b/media/base/media_win.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2009 The Chromium Authors. All rights reserved.
+// Copyright (c) 2010 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -9,6 +9,7 @@
#include "base/file_path.h"
#include "base/logging.h"
#include "base/path_service.h"
+#include "base/scoped_ptr.h"
// Enable timing code by turning on TESTING macro.
//#define TESTING 1
@@ -64,8 +65,17 @@ bool InitializeMediaLibrary(const FilePath& base_path) {
media::FILE_LIBAVUTIL
};
HMODULE libs[arraysize(path_keys)] = {NULL};
+
+ // Limit the DLL search path so we don't load dependencies from the system
+ // path. Refer to http://crbug.com/35857
+ scoped_array<wchar_t> previous_dll_directory(new wchar_t[MAX_PATH]);
+ if (!GetDllDirectory(MAX_PATH, previous_dll_directory.get())) {
+ previous_dll_directory.reset();
+ }
+ SetDllDirectory(base_path.value().c_str());
+
for (size_t i = 0; i < arraysize(path_keys); ++i) {
- FilePath path = base_path.Append(GetDLLName(path_keys[i]));
+ FilePath path(GetDLLName(path_keys[i]));
#ifdef TESTING
double dll_loadtime_start = GetTime();
#endif
@@ -82,6 +92,8 @@ bool InitializeMediaLibrary(const FilePath& base_path) {
#endif
}
+ SetDllDirectory(previous_dll_directory.get());
+
// Check that we loaded all libraries successfully. We only need to check the
// last array element because the loop above will break without initializing
// it on any prior error.