Fixed double-free in case of module loading error.
authorArtem Belevich <tra@google.com>
Tue, 12 May 2015 17:44:15 +0000 (17:44 +0000)
committerArtem Belevich <tra@google.com>
Tue, 12 May 2015 17:44:15 +0000 (17:44 +0000)
commited0577cc6d3a15b4951111e5565a2964b85ab8f4
tree7ccf306aac19f3dbc9f2c3c3e2146277ed5b7e99
parent38bb81db85da12af346922808ae52fa577aafa90
Fixed double-free in case of module loading error.

GetOutputStream() owns the stream it returns pointer to and the
pointer should never be freed by us. When we fail to load and exit
early, unique_ptr still holds the pointer and frees it which leads to
compiler crash when CompilerInstance attempts to free it again.

Added regression test for failed bitcode linking.

Differential Revision: http://reviews.llvm.org/D9625

llvm-svn: 237159
clang/lib/CodeGen/CodeGenAction.cpp
clang/test/CodeGen/link-bitcode-file.c