File tree Expand file tree Collapse file tree 1 file changed +14
-1
lines changed Expand file tree Collapse file tree 1 file changed +14
-1
lines changed Original file line number Diff line number Diff line change @@ -4279,7 +4279,7 @@ os_listdrives_impl(PyObject *module)
4279
4279
str = PyUnicode_FromWideChar (buffer , buflen - 1 );
4280
4280
nullchar = PyUnicode_FromStringAndSize ("\0" , 1 );
4281
4281
if (str && nullchar ) {
4282
- r = PyUnicode_Split (str , nullchar , buflen );
4282
+ r = PyUnicode_Split (str , nullchar , -1 );
4283
4283
}
4284
4284
exit :
4285
4285
if (buffer && buffer != defaultBuffer ) {
@@ -4370,12 +4370,25 @@ os_listmounts_impl(PyObject *module, path_t *volume)
4370
4370
wchar_t default_buffer [MAX_PATH + 1 ];
4371
4371
DWORD buflen = Py_ARRAY_LENGTH (default_buffer );
4372
4372
LPWSTR buffer = default_buffer ;
4373
+ DWORD attributes ;
4373
4374
PyObject * str = NULL ;
4374
4375
PyObject * nullchar = NULL ;
4375
4376
PyObject * result = NULL ;
4377
+
4378
+ /* Ensure we have a valid volume path before continuing */
4379
+ Py_BEGIN_ALLOW_THREADS
4380
+ attributes = GetFileAttributesW (volume -> wide );
4381
+ Py_END_ALLOW_THREADS
4382
+ if (attributes == INVALID_FILE_ATTRIBUTES &&
4383
+
7345
GetLastError () == ERROR_UNRECOGNIZED_VOLUME )
4384
+ {
4385
+ return PyErr_SetFromWindowsErr (ERROR_UNRECOGNIZED_VOLUME );
4386
+ }
4387
+
4376
4388
if (PySys_Audit ("os.listmounts" , "O" , volume -> object ) < 0 ) {
4377
4389
return NULL ;
4378
4390
}
4391
+
4379
4392
while (1 ) {
4380
4393
BOOL success ;
4381
4394
Py_BEGIN_ALLOW_THREADS
You can’t perform that action at this time.
0 commit comments