Bug 1445601 - Stop using LoadLibraryA in replace_malloc. r=njn draft
authorMasatoshi Kimura <VYV03354@nifty.ne.jp>
Sun, 25 Mar 2018 13:12:03 +0900
changeset 772158 3beaca8d96d2a48ef44b7d045f12dc0ae7f364c1
parent 772157 a7bfaf987a23968b626b8157f8f364d9705a813c
child 772159 c27119fe1ba026abe69d2ad9a2c671fc955dd294
push id103861
push userVYV03354@nifty.ne.jp
push dateSun, 25 Mar 2018 05:12:04 +0000
reviewersnjn
bugs1445601
milestone61.0a1
Bug 1445601 - Stop using LoadLibraryA in replace_malloc. r=njn MozReview-Commit-ID: 8EzDtCIlg7F
memory/build/mozjemalloc.cpp
--- a/memory/build/mozjemalloc.cpp
+++ b/memory/build/mozjemalloc.cpp
@@ -120,16 +120,17 @@
 #ifdef XP_DARWIN
 #include <libkern/OSAtomic.h>
 #include <mach/mach_init.h>
 #include <mach/vm_map.h>
 #endif
 
 #include "mozilla/Atomics.h"
 #include "mozilla/Alignment.h"
+#include "mozilla/ArrayUtils.h"
 #include "mozilla/Assertions.h"
 #include "mozilla/Attributes.h"
 #include "mozilla/CheckedInt.h"
 #include "mozilla/DoublyLinkedList.h"
 #include "mozilla/Likely.h"
 #include "mozilla/MathAlgorithms.h"
 #include "mozilla/Sprintf.h"
 // Note: MozTaggedAnonymousMmap() could call an LD_PRELOADed mmap
@@ -4691,21 +4692,21 @@ static replace_init_impl_t* replace_init
 #endif
 
 #ifdef XP_WIN
 typedef HMODULE replace_malloc_handle_t;
 
 static replace_malloc_handle_t
 replace_malloc_handle()
 {
-  char replace_malloc_lib[1024];
-  if (GetEnvironmentVariableA("MOZ_REPLACE_MALLOC_LIB",
+  wchar_t replace_malloc_lib[1024];
+  if (GetEnvironmentVariableW(L"MOZ_REPLACE_MALLOC_LIB",
                               replace_malloc_lib,
-                              sizeof(replace_malloc_lib)) > 0) {
-    return LoadLibraryA(replace_malloc_lib);
+                              ArrayLength(replace_malloc_lib)) > 0) {
+    return LoadLibraryW(replace_malloc_lib);
   }
   return nullptr;
 }
 
 #define REPLACE_MALLOC_GET_INIT_FUNC(handle)                                   \
   (replace_init_impl_t*)GetProcAddress(handle, "replace_init")
 
 #elif defined(ANDROID)