mkstemp fix

`mkstemp` returns a file descriptor.  Trying to `fopen`() that is a bad idea.
This commit is contained in:
ksherlock 2016-02-22 15:45:17 -05:00
parent 4cc8c97be5
commit 80c4aec631

View File

@ -337,7 +337,7 @@ initializeStuff(int argc, char **argv)
installCommandLineDefineSymbols(); installCommandLineDefineSymbols();
if (listingOn) { if (listingOn) {
if ((saveFileForPass2 = fopen(mkstemp(pass2SourceFileName), if ((saveFileForPass2 = fdopen(mkstemp(pass2SourceFileName),
"w+")) == NULL) { "w+")) == NULL) {
fatalSystemError(UNABLE_TO_OPEN_PASS_2_FILE_ERROR, fatalSystemError(UNABLE_TO_OPEN_PASS_2_FILE_ERROR,
pass2SourceFileName); pass2SourceFileName);
@ -346,7 +346,7 @@ initializeStuff(int argc, char **argv)
unlink(pass2SourceFileName); /* will take effect on unlink(pass2SourceFileName); /* will take effect on
program exit */ program exit */
if ((indexFileForPass2 = fopen(mkstemp(pass2IndexFileName), if ((indexFileForPass2 = fdopen(mkstemp(pass2IndexFileName),
"w+")) == NULL) { "w+")) == NULL) {
fatalSystemError(UNABLE_TO_OPEN_PASS_2_FILE_ERROR, fatalSystemError(UNABLE_TO_OPEN_PASS_2_FILE_ERROR,
pass2IndexFileName); pass2IndexFileName);
@ -356,7 +356,7 @@ initializeStuff(int argc, char **argv)
program exit */ program exit */
if (expandMacros) { if (expandMacros) {
if ((macroFileForPass2 = fopen(mkstemp( if ((macroFileForPass2 = fdopen(mkstemp(
pass2MacroExpansionFileName),"w+")) == NULL) { pass2MacroExpansionFileName),"w+")) == NULL) {
fatalSystemError( fatalSystemError(
UNABLE_TO_OPEN_PASS_2_FILE_ERROR, UNABLE_TO_OPEN_PASS_2_FILE_ERROR,