Don't leak image in Surface test.
authormtklein <mtklein@chromium.org>
Sat, 24 Jan 2015 19:27:27 +0000 (11:27 -0800)
committerCommit bot <commit-bot@chromium.org>
Sat, 24 Jan 2015 19:27:27 +0000 (11:27 -0800)
==7023== 5,056 (896 direct, 4,160 indirect) bytes in 8 blocks are definitely lost in loss record 947 of 2,656
==7023==    at 0x4C2B1C7: operator new(unsigned long) (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==7023==    by 0x82CB99: SkNewImageFromBitmapTexture(SkBitmap const&, int, SkSurface::Budgeted) (SkImage_Gpu.cpp:64)
==7023==    by 0x81A1CF: SkSurface_Gpu::onNewImageSnapshot(SkSurface::Budgeted) (SkSurface_Gpu.cpp:50)
==7023==    by 0x694F9D: SkSurface::newImageSnapshot(SkSurface::Budgeted) (SkSurface_Base.h:92)
==7023==    by 0x55EA7C: test_Surface(skiatest::Reporter*, GrContextFactory*) (SurfaceTest.cpp:485)
==7023==    by 0x407CB2: run_test(skiatest::Test*) (DM.cpp:399)
==7023==    by 0x408382: run_enclave_and_gpu_tests(SkTArray<Task, false>*) (DM.cpp:411)
==7023==    by 0x68B71E: SkTaskGroup::wait() (SkTaskGroup.cpp:67)
==7023==    by 0x40934E: dm_main() (DM.cpp:455)
==7023==    by 0x409483: main (DM.cpp:477)

http://build.chromium.org/p/client.skia/builders/Test-Ubuntu12-ShuttleA-GTX550Ti-x86_64-Release-Valgrind/builds/276/steps/dm/logs/stdio

TBR=bsalomon@google.com

BUG=skia:

Review URL: https://codereview.chromium.org/872183002

tests/SurfaceTest.cpp

index 9449014..8cd50dd 100644 (file)
@@ -482,7 +482,7 @@ static void test_surface_budget(skiatest::Reporter* reporter, GrContext* context
             SkASSERT(surface);
             REPORTER_ASSERT(reporter, sbudgeted == is_budgeted(surface));
 
-            SkImage* image = surface->newImageSnapshot(ibudgeted);
+            SkAutoTUnref<SkImage> image(surface->newImageSnapshot(ibudgeted));
 
             // Initially the image shares a texture with the surface, and the surface decides
             // whether it is budgeted or not.