File tree Expand file tree Collapse file tree 2 files changed +19
-0
lines changed Expand file tree Collapse file tree 2 files changed +19
-0
lines changed Original file line number Diff line number Diff line change @@ -59,7 +59,13 @@ INT cmd_path (LPTSTR param)
59
59
}
60
60
else if (dwBuffer > ENV_BUFFER_SIZE )
61
61
{
62
+ LPTSTR pszOldBuffer = pszBuffer ;
62
63
pszBuffer = (LPTSTR )cmd_realloc (pszBuffer , dwBuffer * sizeof (TCHAR ));
64
+ if (pszBuffer == NULL )
65
+ {
66
+ cmd_free (pszOldBuffer );
67
+ return 1 ;
68
+ }
63
69
GetEnvironmentVariable (_T ("PATH" ), pszBuffer , dwBuffer );
64
70
}
65
71
Original file line number Diff line number Diff line change @@ -152,7 +152,13 @@ SearchForExecutable (LPCTSTR pFileName, LPTSTR pFullName)
152
152
dwBuffer = GetEnvironmentVariable (_T ("PATHEXT" ), pszPathExt , ENV_BUFFER_SIZE );
153
153
if (dwBuffer > ENV_BUFFER_SIZE )
154
154
{
155
+ LPTSTR pszOldPathExt = pszPathExt ;
155
156
pszPathExt = (LPTSTR )cmd_realloc (pszPathExt , dwBuffer * sizeof (TCHAR ));
157
+ if (pszPathExt == NULL )
158
+ {
159
+ cmd_free (pszOldPathExt );
160
+ return FALSE;
161
+ }
156
162
GetEnvironmentVariable (_T ("PATHEXT" ), pszPathExt , dwBuffer );
157
163
_tcslwr (pszPathExt );
158
164
}
@@ -184,7 +190,14 @@ SearchForExecutable (LPCTSTR pFileName, LPTSTR pFullName)
184
190
dwBuffer = GetEnvironmentVariable (_T ("PATH" ), pszPath , ENV_BUFFER_SIZE );
185
191
if (dwBuffer > ENV_BUFFER_SIZE )
186
192
{
193
+ LPTSTR pszOldPath = pszPath ;
187
194
pszPath = (LPTSTR )cmd_realloc (pszPath , dwBuffer * sizeof (TCHAR ));
195
+ if (pszPath == NULL )
196
+ {
197
+ cmd_free (pszOldPath );
198
+ cmd_free (pszPathExt );
199
+ return FALSE;
200
+ }
188
201
GetEnvironmentVariable (_T ("PATH" ), pszPath , dwBuffer );
189
202
}
190
203
You can’t perform that action at this time.
0 commit comments