Skip to content

Commit 08ad239

Browse files
committed
Don't include analytics_windows.h except on Windows.
If no hash is passed in, load the DLL indiscriminantly.
1 parent 0026cde commit 08ad239

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

analytics/src/analytics_desktop.cc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919

2020
#include "analytics/src/analytics_common.h"
2121
#include "analytics/src/analytics_desktop_dynamic.h"
22-
#include "analytics/src/analytics_windows.h" // Added for VerifyAndLoadAnalyticsLibrary
2322
#include "analytics/src/include/firebase/analytics.h"
2423
#include "app/src/future_manager.h" // For FutureData
2524
#include "app/src/include/firebase/app.h"
@@ -29,6 +28,8 @@
2928

3029
#if defined(_WIN32)
3130
#include <windows.h>
31+
32+
#include "analytics/src/analytics_windows.h"
3233
#endif // defined(_WIN32)
3334

3435
namespace firebase {

analytics/src/analytics_windows.cc

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,11 +105,15 @@ HMODULE VerifyAndLoadAnalyticsLibrary(
105105
const wchar_t* library_filename, // This is expected to be just the DLL
106106
// filename e.g. "analytics_win.dll"
107107
const unsigned char* expected_hash, size_t expected_hash_size) {
108-
if (library_filename == nullptr || library_filename[0] == L'\0' ||
109-
expected_hash == nullptr || expected_hash_size == 0) {
108+
if (library_filename == nullptr || library_filename[0] == L'\0') {
110109
LogError("VerifyAndLoadAnalyticsLibrary: Invalid arguments.");
111110
return nullptr;
112111
}
112+
if (expected_hash == nullptr || expected_hash_size == 0) {
113+
// Don't check the hash, just load the library.
114+
return LoadLibraryExW(library_filename, NULL,
115+
LOAD_LIBRARY_SEARCH_APPLICATION_DIR);
116+
}
113117

114118
// Get full path to the executable using _wpgmptr.
115119
// This global variable is provided by the CRT and is expected to be available

0 commit comments

Comments
 (0)