[llvm] r192787 - [pr17595] Fix a use after free.
Rafael Espindola
rafael.espindola at gmail.com
Wed Oct 16 05:47:04 PDT 2013
Author: rafael
Date: Wed Oct 16 07:47:04 2013
New Revision: 192787
URL: http://llvm.org/viewvc/llvm-project?rev=192787&view=rev
Log:
[pr17595] Fix a use after free.
Destroying the codegen also frees the path of the created object. Copy the
path to a std::string.
Modified:
llvm/trunk/tools/gold/gold-plugin.cpp
Modified: llvm/trunk/tools/gold/gold-plugin.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/gold/gold-plugin.cpp?rev=192787&r1=192786&r2=192787&view=diff
==============================================================================
--- llvm/trunk/tools/gold/gold-plugin.cpp (original)
+++ llvm/trunk/tools/gold/gold-plugin.cpp Wed Oct 16 07:47:04 2013
@@ -427,9 +427,14 @@ static ld_plugin_status all_symbols_read
exit(0);
}
}
- const char *objPath;
- if (lto_codegen_compile_to_file(code_gen, &objPath)) {
- (*message)(LDPL_ERROR, "Could not produce a combined object file\n");
+
+ std::string ObjPath;
+ {
+ const char *Temp;
+ if (lto_codegen_compile_to_file(code_gen, &Temp)) {
+ (*message)(LDPL_ERROR, "Could not produce a combined object file\n");
+ }
+ ObjPath = Temp;
}
lto_codegen_dispose(code_gen);
@@ -441,9 +446,9 @@ static ld_plugin_status all_symbols_read
}
}
- if ((*add_input_file)(objPath) != LDPS_OK) {
+ if ((*add_input_file)(ObjPath.c_str()) != LDPS_OK) {
(*message)(LDPL_ERROR, "Unable to add .o file to the link.");
- (*message)(LDPL_ERROR, "File left behind in: %s", objPath);
+ (*message)(LDPL_ERROR, "File left behind in: %s", ObjPath.c_str());
return LDPS_ERR;
}
@@ -454,7 +459,7 @@ static ld_plugin_status all_symbols_read
}
if (options::obj_path.empty())
- Cleanup.push_back(objPath);
+ Cleanup.push_back(ObjPath);
return LDPS_OK;
}
More information about the llvm-commits
mailing list