Changeset - r25429:9e7f57ebdc95
[Not reviewed]
master
0 2 0
Rubidium - 3 years ago 2021-05-09 21:00:36
rubidium@openttd.org
Fix: leaking file descriptors
2 files changed with 9 insertions and 2 deletions:
0 comments (0 inline, 0 general)
src/console_cmds.cpp
Show inline comments
 
@@ -939,6 +939,7 @@ DEF_CONSOLE_CMD(ConExec)
 
	}
 

	
 
	if (_script_current_depth == 11) {
 
		FioFCloseFile(script_file);
 
		IConsoleError("Maximum 'exec' depth reached; script A is calling script B is calling script C ... more than 10 times.");
 
		return true;
 
	}
src/network/network_content.cpp
Show inline comments
 
@@ -410,7 +410,8 @@ static bool GunzipFile(const ContentInfo
 
	FILE *ftmp = fopen(GetFullFilename(ci, true).c_str(), "rb");
 
	if (ftmp == nullptr) return false;
 
	/* Duplicate the handle, and close the FILE*, to avoid double-closing the handle later. */
 
	gzFile fin = gzdopen(dup(fileno(ftmp)), "rb");
 
	int fdup = dup(fileno(ftmp));
 
	gzFile fin = gzdopen(fdup, "rb");
 
	fclose(ftmp);
 

	
 
	FILE *fout = fopen(GetFullFilename(ci, false).c_str(), "wb");
 
@@ -449,7 +450,12 @@ static bool GunzipFile(const ContentInfo
 
		}
 
	}
 

	
 
	if (fin != nullptr) gzclose(fin);
 
	if (fin != nullptr) {
 
		gzclose(fin);
 
	} else if (fdup != -1) {
 
		/* Failing gzdopen does not close the passed file descriptor. */
 
		close(fdup);
 
	}
 
	if (fout != nullptr) fclose(fout);
 

	
 
	return ret;
0 comments (0 inline, 0 general)