OSDN Git Service

Fix memory leak of Subzero global inits.
authorNicolas Capens <capn@google.com>
Wed, 5 Jul 2017 19:04:00 +0000 (15:04 -0400)
committerNicolas Capens <capn@google.com>
Wed, 5 Jul 2017 19:16:05 +0000 (19:16 +0000)
getGlobalInits() moves ownership of a unique_ptr<>, which we released
to obtain the raw pointer, but we didn't delete it afterwards. This is
fixed by keeping the unique_ptr<> and having it freed at the end of the
scope.

Bug chromium:732739

Change-Id: I4d8c9367f34790944daabc0417af08eb4b4c7c2e
Reviewed-on: https://swiftshader-review.googlesource.com/10409
Tested-by: Nicolas Capens <capn@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <capn@google.com>
src/Reactor/SubzeroReactor.cpp

index aeed845..fc70ac2 100644 (file)
@@ -587,11 +587,11 @@ namespace sw
                ::function->translate();
                assert(!::function->hasError());
 
-               auto *globals = ::function->getGlobalInits().release();
+               auto globals = ::function->getGlobalInits();
 
                if(globals && !globals->empty())
                {
-                       ::context->getGlobals()->merge(globals);
+                       ::context->getGlobals()->merge(globals.get());
                }
 
                ::context->emitFileHeader();