Sat, 03 Jan 2015 20:18:00 +0100
Conditionally enable double key logic according to:
private browsing mode or privacy.thirdparty.isolate preference and
implement in GetCookieStringCommon and FindCookie where it counts...
With some reservations of how to convince FindCookie users to test
condition and pass a nullptr when disabling double key logic.
1 #define MOZ_NONHEAP_CLASS __attribute__((annotate("moz_nonheap_class")))
2 #define MOZ_HEAP_ALLOCATOR \
3 _Pragma("GCC diagnostic push") \
4 _Pragma("GCC diagnostic ignored \"-Wgcc-compat\"") \
5 __attribute__((annotate("moz_heap_allocator"))) \
6 _Pragma("GCC diagnostic pop")
8 #include <stdlib.h>
9 #include <memory>
11 struct MOZ_NONHEAP_CLASS X {
12 };
14 void *operator new(size_t x, int qual) MOZ_HEAP_ALLOCATOR {
15 return ::operator new(x);
16 }
18 template <typename T>
19 T *customAlloc() MOZ_HEAP_ALLOCATOR {
20 T *arg = static_cast<T*>(malloc(sizeof(T)));
21 return new (arg) T();
22 }
24 template <typename T>
25 void misuseX(T q) {
26 X *foo = customAlloc<X>(); // expected-error {{variable of type 'X' is not valid on the heap}}
27 X *foo2 = new (100) X(); // expected-error {{variable of type 'X' is not valid on the heap}}
28 }