File tree Expand file tree Collapse file tree 1 file changed +12
-4
lines changed Expand file tree Collapse file tree 1 file changed +12
-4
lines changed Original file line number Diff line number Diff line change @@ -260,7 +260,12 @@ PyLocale_strxfrm(PyObject* self, PyObject* args)
260
260
PyErr_NoMemory ();
261
261
goto exit ;
262
262
}
263
+ errno = 0 ;
263
264
n2 = wcsxfrm (buf , s , n1 );
265
+ if (errno ) {
266
+ PyErr_SetFromErrno (PyExc_OSError );
267
+ goto exit ;
268
+ }
264
269
if (n2 >= (size_t )n1 ) {
265
270
/* more space needed */
266
271
wchar_t * new_buf = PyMem_Realloc (buf , (n2 + 1 )* sizeof (wchar_t ));
@@ -269,14 +274,17 @@ PyLocale_strxfrm(PyObject* self, PyObject* args)
269
274
goto exit ;
270
275
}
271
276
buf = new_buf ;
277
+ errno = 0 ;
272
278
n2 = wcsxfrm (buf , s , n2 + 1 );
279
+ if (errno ) {
280
+ PyErr_SetFromErrno (PyExc_OSError );
281
+ goto exit ;
282
+ }
273
283
}
274
284
result = PyUnicode_FromWideChar (buf , n2 );
275
285
exit :
276
- if (buf )
277
- PyMem_Free (buf );
278
- if (s )
279
- PyMem_Free (s );
286
+ PyMem_Free (buf );
287
+ PyMem_Free (s );
280
288
return result ;
281
289
}
282
290
#endif
You can’t perform that action at this time.
0 commit comments