16e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)// Copyright (c) 2013 The Chromium Authors. All rights reserved. 26e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)// Use of this source code is governed by a BSD-style license that can be 36e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)// found in the LICENSE file. 46e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) 56e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)#include "scoped_refptr.h" 66e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) 76e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)struct Foo { 86e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) int dummy; 96e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)}; 106e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) 1103b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles)// An example of an unsafe conversion, where the object is freed by the time the 1203b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles)// function returns. 1303b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles)Foo* GetBuggyFoo(); 1403b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles) 156e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)Foo* GetBuggyFoo() { 166e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) scoped_refptr<Foo> unsafe(new Foo); 176e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) return unsafe; 186e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)} 19