Fossil SCM
plug minor memory leak
Commit
52fb2a71ad2a8164002e5a1bb13e7c1e8c5c07d7
Parent
26ad1bce4959903…
1 file changed
+8
-4
+8
-4
| --- src/file.c | ||
| +++ src/file.c | ||
| @@ -1011,23 +1011,26 @@ | ||
| 1011 | 1011 | |
| 1012 | 1012 | /* |
| 1013 | 1013 | ** Construct a random temporary filename into zBuf[]. |
| 1014 | 1014 | */ |
| 1015 | 1015 | void file_tempname(int nBuf, char *zBuf){ |
| 1016 | - static const char *azDirs[] = { | |
| 1017 | 1016 | #if defined(_WIN32) |
| 1017 | + const char *azDirs[] = { | |
| 1018 | 1018 | 0, /* GetTempPath */ |
| 1019 | 1019 | 0, /* TEMP */ |
| 1020 | 1020 | 0, /* TMP */ |
| 1021 | + ".", | |
| 1022 | + }; | |
| 1021 | 1023 | #else |
| 1024 | + static const char *azDirs[] = { | |
| 1022 | 1025 | "/var/tmp", |
| 1023 | 1026 | "/usr/tmp", |
| 1024 | 1027 | "/tmp", |
| 1025 | 1028 | "/temp", |
| 1026 | -#endif | |
| 1027 | 1029 | ".", |
| 1028 | 1030 | }; |
| 1031 | +#endif | |
| 1029 | 1032 | static const unsigned char zChars[] = |
| 1030 | 1033 | "abcdefghijklmnopqrstuvwxyz" |
| 1031 | 1034 | "ABCDEFGHIJKLMNOPQRSTUVWXYZ" |
| 1032 | 1035 | "0123456789"; |
| 1033 | 1036 | unsigned int i, j; |
| @@ -1070,12 +1073,13 @@ | ||
| 1070 | 1073 | } |
| 1071 | 1074 | zBuf[j] = 0; |
| 1072 | 1075 | }while( file_size(zBuf)>=0 ); |
| 1073 | 1076 | |
| 1074 | 1077 | #if defined(_WIN32) |
| 1075 | - fossil_unicode_free((char *)azDirs[1]); | |
| 1076 | - fossil_unicode_free((char *)azDirs[2]); | |
| 1078 | + fossil_filename_free((char *)azDirs[0]); | |
| 1079 | + fossil_filename_free((char *)azDirs[1]); | |
| 1080 | + fossil_filename_free((char *)azDirs[2]); | |
| 1077 | 1081 | #endif |
| 1078 | 1082 | } |
| 1079 | 1083 | |
| 1080 | 1084 | |
| 1081 | 1085 | /* |
| 1082 | 1086 |
| --- src/file.c | |
| +++ src/file.c | |
| @@ -1011,23 +1011,26 @@ | |
| 1011 | |
| 1012 | /* |
| 1013 | ** Construct a random temporary filename into zBuf[]. |
| 1014 | */ |
| 1015 | void file_tempname(int nBuf, char *zBuf){ |
| 1016 | static const char *azDirs[] = { |
| 1017 | #if defined(_WIN32) |
| 1018 | 0, /* GetTempPath */ |
| 1019 | 0, /* TEMP */ |
| 1020 | 0, /* TMP */ |
| 1021 | #else |
| 1022 | "/var/tmp", |
| 1023 | "/usr/tmp", |
| 1024 | "/tmp", |
| 1025 | "/temp", |
| 1026 | #endif |
| 1027 | ".", |
| 1028 | }; |
| 1029 | static const unsigned char zChars[] = |
| 1030 | "abcdefghijklmnopqrstuvwxyz" |
| 1031 | "ABCDEFGHIJKLMNOPQRSTUVWXYZ" |
| 1032 | "0123456789"; |
| 1033 | unsigned int i, j; |
| @@ -1070,12 +1073,13 @@ | |
| 1070 | } |
| 1071 | zBuf[j] = 0; |
| 1072 | }while( file_size(zBuf)>=0 ); |
| 1073 | |
| 1074 | #if defined(_WIN32) |
| 1075 | fossil_unicode_free((char *)azDirs[1]); |
| 1076 | fossil_unicode_free((char *)azDirs[2]); |
| 1077 | #endif |
| 1078 | } |
| 1079 | |
| 1080 | |
| 1081 | /* |
| 1082 |
| --- src/file.c | |
| +++ src/file.c | |
| @@ -1011,23 +1011,26 @@ | |
| 1011 | |
| 1012 | /* |
| 1013 | ** Construct a random temporary filename into zBuf[]. |
| 1014 | */ |
| 1015 | void file_tempname(int nBuf, char *zBuf){ |
| 1016 | #if defined(_WIN32) |
| 1017 | const char *azDirs[] = { |
| 1018 | 0, /* GetTempPath */ |
| 1019 | 0, /* TEMP */ |
| 1020 | 0, /* TMP */ |
| 1021 | ".", |
| 1022 | }; |
| 1023 | #else |
| 1024 | static const char *azDirs[] = { |
| 1025 | "/var/tmp", |
| 1026 | "/usr/tmp", |
| 1027 | "/tmp", |
| 1028 | "/temp", |
| 1029 | ".", |
| 1030 | }; |
| 1031 | #endif |
| 1032 | static const unsigned char zChars[] = |
| 1033 | "abcdefghijklmnopqrstuvwxyz" |
| 1034 | "ABCDEFGHIJKLMNOPQRSTUVWXYZ" |
| 1035 | "0123456789"; |
| 1036 | unsigned int i, j; |
| @@ -1070,12 +1073,13 @@ | |
| 1073 | } |
| 1074 | zBuf[j] = 0; |
| 1075 | }while( file_size(zBuf)>=0 ); |
| 1076 | |
| 1077 | #if defined(_WIN32) |
| 1078 | fossil_filename_free((char *)azDirs[0]); |
| 1079 | fossil_filename_free((char *)azDirs[1]); |
| 1080 | fossil_filename_free((char *)azDirs[2]); |
| 1081 | #endif |
| 1082 | } |
| 1083 | |
| 1084 | |
| 1085 | /* |
| 1086 |