Fix memory leak of Subzero global inits.
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>
diff --git a/src/Reactor/SubzeroReactor.cpp b/src/Reactor/SubzeroReactor.cpp
index aeed845..fc70ac2 100644
--- a/src/Reactor/SubzeroReactor.cpp
+++ b/src/Reactor/SubzeroReactor.cpp
@@ -587,11 +587,11 @@
::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();