File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -353,6 +353,7 @@ _Py_wrealpath(const wchar_t *path,
353353{
354354 char * cpath ;
355355 char cresolved_path [PATH_MAX ];
356+ wchar_t * wresolved_path ;
356357 char * res ;
357358 size_t r ;
358359 cpath = _Py_wchar2char (path );
@@ -364,11 +365,20 @@ _Py_wrealpath(const wchar_t *path,
364365 PyMem_Free (cpath );
365366 if (res == NULL )
366367 return NULL ;
367- r = mbstowcs (resolved_path , cresolved_path , resolved_path_size );
368- if (r == (size_t )-1 || r >= PATH_MAX ) {
368+
369+ wresolved_path = _Py_char2wchar (cresolved_path );
370+ if (wresolved_path == NULL ) {
371+ errno = EINVAL ;
372+ return NULL ;
373+ }
374+ r = wcslen (wresolved_path );
375+ if (resolved_path_size <= r ) {
376+ PyMem_Free (wresolved_path );
369377 errno = EINVAL ;
370378 return NULL ;
371379 }
380+ wcsncpy (resolved_path , wresolved_path , resolved_path_size );
381+ PyMem_Free (wresolved_path );
372382 return resolved_path ;
373383}
374384#endif
You can’t perform that action at this time.
0 commit comments