Bug 1432239 Declare operator new [](size_t, sandbox::AllocationType, void*) r?bobowen draft
authorTom Ritter <tom@mozilla.com>
Wed, 08 Mar 2017 19:16:46 +0000
changeset 723579 d52aa31d6bf56a24315f07a43a52a810baee1652
parent 723578 90f3c179e59ca15d8388f321259743e86074352d
child 723580 9396403dab010bdb2ef1cf6f76ce3a04f6a964d8
push id96471
push userbmo:tom@mozilla.com
push dateTue, 23 Jan 2018 15:26:55 +0000
reviewersbobowen
bugs1432239
milestone59.0a1
Bug 1432239 Declare operator new [](size_t, sandbox::AllocationType, void*) r?bobowen MozReview-Commit-ID: GCKj5Ao2Y2n
security/sandbox/chromium-shim/patches/with_update/mingw_operator_new.patch
security/sandbox/chromium-shim/patches/with_update/patch_order.txt
security/sandbox/chromium/sandbox/win/src/sandbox_nt_util.cc
security/sandbox/chromium/sandbox/win/src/sandbox_nt_util.h
new file mode 100644
--- /dev/null
+++ b/security/sandbox/chromium-shim/patches/with_update/mingw_operator_new.patch
@@ -0,0 +1,57 @@
+# HG changeset patch
+# User Tom Ritter <tom@mozilla.com>
+# Date 1489000606 0
+#      Wed Mar 08 19:16:46 2017 +0000
+# Node ID 522c35c24e2a46d97430b5f15e7703bc1c33784c
+# Parent  a99512c712f6580537e3133e5fd1adc091583e95
+Bug 1230910 Declare operator new [](size_t, sandbox::AllocationType, void*)
+
+MozReview-Commit-ID: GCKj5Ao2Y2n
+
+diff --git a/security/sandbox/chromium/sandbox/win/src/sandbox_nt_util.cc b/security/sandbox/chromium/sandbox/win/src/sandbox_nt_util.cc
+--- a/security/sandbox/chromium/sandbox/win/src/sandbox_nt_util.cc
++++ b/security/sandbox/chromium/sandbox/win/src/sandbox_nt_util.cc
+@@ -649,16 +649,21 @@ void* operator new(size_t size, sandbox:
+ 
+   // TODO: Returning NULL from operator new has undefined behavior, but
+   // the Allocate() functions called above can return NULL. Consider checking
+   // for NULL here and crashing or throwing.
+ 
+   return result;
+ }
+ 
++void* operator new [](size_t size, sandbox::AllocationType type,
++		      void* near_to) {
++  return operator new(size, type, near_to);
++}
++
+ void operator delete(void* memory, sandbox::AllocationType type) {
+   if (type == sandbox::NT_ALLOC) {
+     // Use default flags.
+     VERIFY(sandbox::g_nt.RtlFreeHeap(sandbox::g_heap, 0, memory));
+   } else if (type == sandbox::NT_PAGE) {
+     void* base = memory;
+     SIZE_T size = 0;
+     VERIFY_SUCCESS(sandbox::g_nt.FreeVirtualMemory(NtCurrentProcess, &base,
+diff --git a/security/sandbox/chromium/sandbox/win/src/sandbox_nt_util.h b/security/sandbox/chromium/sandbox/win/src/sandbox_nt_util.h
+--- a/security/sandbox/chromium/sandbox/win/src/sandbox_nt_util.h
++++ b/security/sandbox/chromium/sandbox/win/src/sandbox_nt_util.h
+@@ -11,16 +11,18 @@
+ 
+ #include "base/macros.h"
+ #include "sandbox/win/src/nt_internals.h"
+ #include "sandbox/win/src/sandbox_nt_types.h"
+ 
+ // Placement new and delete to be used from ntdll interception code.
+ void* __cdecl operator new(size_t size, sandbox::AllocationType type,
+                            void* near_to = NULL);
++void* __cdecl operator new[](size_t size, sandbox::AllocationType type,
++			     void* near_to = NULL);
+ void __cdecl operator delete(void* memory, sandbox::AllocationType type);
+ // Add operator delete that matches the placement form of the operator new
+ // above. This is required by compiler to generate code to call operator delete
+ // in case the object's constructor throws an exception.
+ // See http://msdn.microsoft.com/en-us/library/cxdxz3x6.aspx
+ void __cdecl operator delete(void* memory, sandbox::AllocationType type,
+                              void* near_to);
+ 
--- a/security/sandbox/chromium-shim/patches/with_update/patch_order.txt
+++ b/security/sandbox/chromium-shim/patches/with_update/patch_order.txt
@@ -9,9 +9,10 @@ ifdef_out_SequenceChecker_code.patch
 revert_c++14_typename_alias_usage.patch
 revert_c++14_index_sequence_usage.patch
 fix_Wcomma_warning_in_time_cc.patch
 allow_read_only_all_paths_rule.patch
 revert_TargetNtSetInformationThread_change.patch
 mingw_base_win_get_caller.patch
 mingw_duplicate_instatinations.patch
 mingw_msvc_requirement_error.patch
-mingw_copy_s.patch
\ No newline at end of file
+mingw_copy_s.patch
+mingw_operator_new.patch
\ No newline at end of file
--- a/security/sandbox/chromium/sandbox/win/src/sandbox_nt_util.cc
+++ b/security/sandbox/chromium/sandbox/win/src/sandbox_nt_util.cc
@@ -649,16 +649,21 @@ void* operator new(size_t size, sandbox:
 
   // TODO: Returning NULL from operator new has undefined behavior, but
   // the Allocate() functions called above can return NULL. Consider checking
   // for NULL here and crashing or throwing.
 
   return result;
 }
 
+void* operator new [](size_t size, sandbox::AllocationType type,
+		      void* near_to) {
+  return operator new(size, type, near_to);
+}
+
 void operator delete(void* memory, sandbox::AllocationType type) {
   if (type == sandbox::NT_ALLOC) {
     // Use default flags.
     VERIFY(sandbox::g_nt.RtlFreeHeap(sandbox::g_heap, 0, memory));
   } else if (type == sandbox::NT_PAGE) {
     void* base = memory;
     SIZE_T size = 0;
     VERIFY_SUCCESS(sandbox::g_nt.FreeVirtualMemory(NtCurrentProcess, &base,
--- a/security/sandbox/chromium/sandbox/win/src/sandbox_nt_util.h
+++ b/security/sandbox/chromium/sandbox/win/src/sandbox_nt_util.h
@@ -11,16 +11,18 @@
 
 #include "base/macros.h"
 #include "sandbox/win/src/nt_internals.h"
 #include "sandbox/win/src/sandbox_nt_types.h"
 
 // Placement new and delete to be used from ntdll interception code.
 void* __cdecl operator new(size_t size, sandbox::AllocationType type,
                            void* near_to = NULL);
+void* __cdecl operator new[](size_t size, sandbox::AllocationType type,
+			     void* near_to = NULL);
 void __cdecl operator delete(void* memory, sandbox::AllocationType type);
 // Add operator delete that matches the placement form of the operator new
 // above. This is required by compiler to generate code to call operator delete
 // in case the object's constructor throws an exception.
 // See http://msdn.microsoft.com/en-us/library/cxdxz3x6.aspx
 void __cdecl operator delete(void* memory, sandbox::AllocationType type,
                              void* near_to);