示例#1
0
#pragma warning disable CS1591
        protected unsafe override void Dispose(bool disposing)
        {
            IntPtr mem = (IntPtr)_instance;
            bool   alive;

            lock (Scope)
            {
                alive = Scope.Remove(mem);
            }
            if (alive)
            {
                CefStructure.Free(mem);
                _instance = null;
            }
        }
示例#2
0
#pragma warning disable CS1591
        protected unsafe override void Dispose(bool disposing)
        {
            IntPtr key = Volatile.Read(ref _instance);

            if (key != IntPtr.Zero)
            {
                GlobalSyncRoot.EnterWriteLock();
                try
                {
                    if (CefApi.UseUnsafeImplementation)
                    {
                        RefCountedWrapperStruct *ws = GetWrapperStructPtr((void *)key);
                        if (ws != null)
                        {
                            UnsafeRefCounted.Remove(ws->cppObject);
                        }
                    }
                    RefCounted.Remove(key);
                }
                finally
                {
                    GlobalSyncRoot.ExitWriteLock();
                }
#if NETFRAMEWORK
                if (Environment.HasShutdownStarted)
                {
                    if (CefStructure.IsAllocated(key))                     // allow leaks to fix potential UAF
                    {
                        return;
                    }
                }
                else
#endif
                if (CefStructure.Free(key))
                {
                    return;
                }

                base.Dispose(disposing);
            }
        }