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.
michael@0 | 1 | #define MOZ_NONHEAP_CLASS __attribute__((annotate("moz_nonheap_class"))) |
michael@0 | 2 | #define MOZ_HEAP_ALLOCATOR \ |
michael@0 | 3 | _Pragma("GCC diagnostic push") \ |
michael@0 | 4 | _Pragma("GCC diagnostic ignored \"-Wgcc-compat\"") \ |
michael@0 | 5 | __attribute__((annotate("moz_heap_allocator"))) \ |
michael@0 | 6 | _Pragma("GCC diagnostic pop") |
michael@0 | 7 | |
michael@0 | 8 | #include <stdlib.h> |
michael@0 | 9 | #include <memory> |
michael@0 | 10 | |
michael@0 | 11 | struct MOZ_NONHEAP_CLASS X { |
michael@0 | 12 | }; |
michael@0 | 13 | |
michael@0 | 14 | void *operator new(size_t x, int qual) MOZ_HEAP_ALLOCATOR { |
michael@0 | 15 | return ::operator new(x); |
michael@0 | 16 | } |
michael@0 | 17 | |
michael@0 | 18 | template <typename T> |
michael@0 | 19 | T *customAlloc() MOZ_HEAP_ALLOCATOR { |
michael@0 | 20 | T *arg = static_cast<T*>(malloc(sizeof(T))); |
michael@0 | 21 | return new (arg) T(); |
michael@0 | 22 | } |
michael@0 | 23 | |
michael@0 | 24 | template <typename T> |
michael@0 | 25 | void misuseX(T q) { |
michael@0 | 26 | X *foo = customAlloc<X>(); // expected-error {{variable of type 'X' is not valid on the heap}} |
michael@0 | 27 | X *foo2 = new (100) X(); // expected-error {{variable of type 'X' is not valid on the heap}} |
michael@0 | 28 | } |