-//
-// Copyright (c) Microsoft. All rights reserved.
-// Licensed under the MIT license. See LICENSE file in the project root for full license information.
-//
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
/*++
SET_DEFAULT_DEBUG_CHANNEL(MEM);
+#ifdef TIZEN_ASAN_ENVIRONMENT
+extern "C" {
+extern void __sanitizer_disable_interceptors() __attribute__ ((weak));
+extern void __sanitizer_enable_interceptors() __attribute__ ((weak));
+extern bool __sanitizer_interceptors_are_enabled() __attribute__ ((weak));
+}
+#endif
+
static
int
AllocFlagsToHeapAllocFlags (IN UINT AllocFlags,
goto done;
}
- lpRetVal = HeapAlloc( GetProcessHeap(), uFlags, uBytes );
+#ifdef TIZEN_ASAN_ENVIRONMENT
+ if (__sanitizer_interceptors_are_enabled != NULL)
+ {
+ bool san_enabled;
+ san_enabled = __sanitizer_interceptors_are_enabled();
+ if (!san_enabled) {
+ __sanitizer_enable_interceptors();
+ }
+ lpRetVal = HeapAlloc( GetProcessHeap(), uFlags, uBytes );
+ if (!san_enabled) {
+ __sanitizer_disable_interceptors();
+ }
+ }
+ else
+#endif
+ {
+ lpRetVal = HeapAlloc( GetProcessHeap(), uFlags, uBytes );
+ }
done:
LOGEXIT( "LocalAlloc returning %p.\n", lpRetVal );
return (HLOCAL) lpRetVal;
}
+/*++
+Function:
+LocalReAlloc
+
+See MSDN doc.
+--*/
+HLOCAL
+PALAPI
+LocalReAlloc(
+ IN HLOCAL hMem,
+ IN SIZE_T uBytes,
+ IN UINT uFlags)
+{
+ LPVOID lpRetVal = NULL;
+ PERF_ENTRY(LocalReAlloc);
+ ENTRY("LocalReAlloc (hMem=%p, uBytes=%u, uFlags=%#x)\n", hMem, uBytes, uFlags);
+
+ if (uFlags != LMEM_MOVEABLE) {
+ // Currently valid iff uFlags is LMEM_MOVEABLE
+ ASSERT("Invalid parameter uFlags=0x%x\n", uFlags);
+ SetLastError(ERROR_INVALID_PARAMETER);
+ goto done;
+ }
+ uFlags = 0;
+
+ lpRetVal = HeapReAlloc(GetProcessHeap(), uFlags, hMem, uBytes);
+
+done:
+ LOGEXIT("LocalReAlloc returning %p.\n", lpRetVal);
+ PERF_EXIT(LocalReAlloc);
+ return (HLOCAL)lpRetVal;
+}
/*++
Function:
if ( hMem )
{
- bRetVal = HeapFree( GetProcessHeap(), 0, hMem );
+#ifdef TIZEN_ASAN_ENVIRONMENT
+ if (__sanitizer_interceptors_are_enabled != NULL)
+ {
+ bool san_enabled;
+ san_enabled = __sanitizer_interceptors_are_enabled();
+ if (!san_enabled) {
+ __sanitizer_enable_interceptors();
+ }
+ bRetVal = HeapFree( GetProcessHeap(), 0, hMem );
+ if (!san_enabled) {
+ __sanitizer_disable_interceptors();
+ }
+ }
+ else
+#endif
+ {
+ bRetVal = HeapFree( GetProcessHeap(), 0, hMem );
+ }
+
}
else
{