Bug 1445601 - Stop using LoadLibraryA in replace_malloc. r=glandium draft
authorMasatoshi Kimura <VYV03354@nifty.ne.jp>
Sun, 25 Mar 2018 13:12:03 +0900
changeset 781697 cf909f472c1c0007b2ff759d011435b8b6bc0f37
parent 781696 966ffb04fa7e4419ae12697adbe53d670450d909
child 781698 0e93acecfe0c9ccd2e4ba9ad3126b6ae16433387
push id106376
push userVYV03354@nifty.ne.jp
push dateFri, 13 Apr 2018 12:58:12 +0000
reviewersglandium
bugs1445601
milestone61.0a1
Bug 1445601 - Stop using LoadLibraryA in replace_malloc. r=glandium 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
@@ -4680,21 +4681,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)