File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1616 Return a pointer to a newly allocated wide character string (use
1717 PyMem_Free() to free the memory) and write the number of written wide
1818 characters excluding the null character into *size if size is not NULL, or
19- NULL on error (conversion error or memory error). */
19+ NULL on error (conversion or memory allocation error).
20+
21+ Conversion errors should never happen, unless there is a bug in the C
22+ library. */
2023wchar_t *
2124_Py_char2wchar (const char * arg , size_t * size )
2225{
@@ -64,7 +67,8 @@ _Py_char2wchar(const char* arg, size_t *size)
6467 actual output could use less memory. */
6568 argsize = strlen (arg ) + 1 ;
6669 res = (wchar_t * )PyMem_Malloc (argsize * sizeof (wchar_t ));
67- if (!res ) goto oom ;
70+ if (!res )
71+ goto oom ;
6872 in = (unsigned char * )arg ;
6973 out = res ;
7074 memset (& mbs , 0 , sizeof mbs );
@@ -79,6 +83,7 @@ _Py_char2wchar(const char* arg, size_t *size)
7983 unless there is a bug in the C library, or I
8084 misunderstood how mbrtowc works. */
8185 fprintf (stderr , "unexpected mbrtowc result -2\n" );
86+ PyMem_Free (res );
8287 return NULL ;
8388 }
8489 if (converted == (size_t )-1 ) {
You can’t perform that action at this time.
0 commit comments