File tree Expand file tree Collapse file tree 1 file changed +5
-3
lines changed Expand file tree Collapse file tree 1 file changed +5
-3
lines changed Original file line number Diff line number Diff line change @@ -1194,7 +1194,7 @@ P_get(void *ptr, Py_ssize_t size)
1194
1194
1195
1195
/* Table with info about all formats.
1196
1196
* Must be accessed via _ctypes_get_fielddesc, which initializes it on
1197
- * first use.
1197
+ * first use. After initialization it's treated as constant & read-only.
1198
1198
*/
1199
1199
1200
1200
struct formattable {
@@ -1464,12 +1464,14 @@ _Py_COMP_DIAG_POP
1464
1464
struct fielddesc *
1465
1465
_ctypes_get_fielddesc (const char * fmt )
1466
1466
{
1467
- static int initialized = 0 ;
1467
+ static bool initialized = 0 ;
1468
+ static PyMutex mutex = {0 };
1469
+ PyMutex_Lock (& mutex );
1468
1470
if (!initialized ) {
1469
1471
_ctypes_init_fielddesc ();
1470
-
1471
1472
initialized = 1 ;
1472
1473
}
1474
+ PyMutex_Unlock (& mutex );
1473
1475
struct fielddesc * result = NULL ;
1474
1476
switch (fmt [0 ]) {
1475
1477
/*[python input]
You can’t perform that action at this time.
0 commit comments