@@ -270,32 +270,24 @@ canonicalize(wchar_t *buffer, const wchar_t *path)
270
270
}
271
271
272
272
273
- /* gotlandmark only called by search_for_prefix, which ensures
274
- 'prefix' is null terminated in bounds. join() ensures
275
- 'landmark' can not overflow prefix if too long. */
273
+ /* assumes argv0_path is MAXPATHLEN+1 bytes long, already \0 term'd.
274
+ assumption provided by only caller, calculate_path() */
276
275
static int
277
- gotlandmark ( const wchar_t * prefix )
276
+ search_for_prefix ( wchar_t * prefix , const wchar_t * argv0_path )
278
277
{
279
278
wchar_t filename [MAXPATHLEN + 1 ];
280
279
memset (filename , 0 , sizeof (filename ));
281
- wcscpy_s (filename , Py_ARRAY_LENGTH (filename ), prefix );
280
+ /* Search from argv0_path, until LANDMARK is found.
281
+ We guarantee 'prefix' is null terminated in bounds. */
282
+ wcscpy_s (prefix , MAXPATHLEN + 1 , argv0_path );
283
+ do {
284
+ wcscpy_s (filename , Py_ARRAY_LENGTH (filename ), prefix );
282
285
#ifndef LANDMARK
283
286
# define LANDMARK L"lib\\os.py"
284
287
#endif
285
- join (filename , LANDMARK );
286
- return ismodule (filename );
287
- }
288
-
289
-
290
- /* assumes argv0_path is MAXPATHLEN+1 bytes long, already \0 term'd.
291
- assumption provided by only caller, calculate_path() */
292
- static int
293
- search_for_prefix (wchar_t * prefix , const wchar_t * argv0_path )
294
- {
295
- /* Search from argv0_path, until landmark is found */
296
- wcscpy_s (prefix , MAXPATHLEN + 1 , argv0_path );
297
- do {
298
- if (gotlandmark (prefix )) {
288
+ /* join() ensures 'landmark' can not overflow prefix if too long. */
289
+ join (filename , LANDMARK );
290
+ if (ismodule (filename )) {
299
291
return 1 ;
300
292
}
301
293
reduce (prefix );
0 commit comments