[ttssh2-commit] [9714] メモリ解放漏れを修正

Back to archive index
scmno****@osdn***** scmno****@osdn*****
2022年 2月 1日 (火) 21:30:09 JST


Revision: 9714
          https://osdn.net/projects/ttssh2/scm/svn/commits/9714
Author:   nmaya
Date:     2022-02-01 21:30:09 +0900 (Tue, 01 Feb 2022)
Log Message:
-----------
メモリ解放漏れを修正

Modified Paths:
--------------
    trunk/teraterm/teraterm/filesys_log.cpp
    trunk/teraterm/teraterm/vtwin.cpp

-------------- next part --------------
Modified: trunk/teraterm/teraterm/filesys_log.cpp
===================================================================
--- trunk/teraterm/teraterm/filesys_log.cpp	2022-01-30 16:14:03 UTC (rev 9713)
+++ trunk/teraterm/teraterm/filesys_log.cpp	2022-02-01 12:30:09 UTC (rev 9714)
@@ -1344,10 +1344,10 @@
  */
 wchar_t *FLogGetLogFilename(const wchar_t *log_filename)
 {
-	const char *logdir;
+	char *logdir;
 
 	if (strlen(ts.LogDefaultPath) > 0) {
-		logdir = ts.LogDefaultPath;
+		logdir = strdup(ts.LogDefaultPath);
 	}
 	else {
 		logdir = ToCharW(ts.LogDirW);
@@ -1370,6 +1370,7 @@
 	ParseStrftimeFileName(full_path, sizeof(full_path));
 	ConvertLogname(full_path, sizeof(full_path));
 
+	free(logdir);
 	return ToWcharA(full_path);
 }
 

Modified: trunk/teraterm/teraterm/vtwin.cpp
===================================================================
--- trunk/teraterm/teraterm/vtwin.cpp	2022-01-30 16:14:03 UTC (rev 9713)
+++ trunk/teraterm/teraterm/vtwin.cpp	2022-02-01 12:30:09 UTC (rev 9714)
@@ -3343,7 +3343,9 @@
 			ts.LogFNW = FLogGetLogFilename(NULL);
 		}
 		else {
-			ts.LogFNW = FLogGetLogFilename(ToWcharA(ts.LogFN));
+			wchar_t *LogFNW = ToWcharA(ts.LogFN);
+			ts.LogFNW = FLogGetLogFilename(LogFNW);
+			free(LogFNW);
 		}
 		WideCharToACP_t(ts.LogFNW, ts.LogFN, sizeof(ts.LogFN));
 		if (ts.LogFN[0]!=0) {


ttssh2-commit メーリングリストの案内
Back to archive index