Issue #18408: Fix PyCStructUnionType_update_stgdict(), handle
_ctypes_alloc_format_string() failure
diff --git a/Modules/_ctypes/stgdict.c b/Modules/_ctypes/stgdict.c
index 25d9996..b95b0a4 100644
--- a/Modules/_ctypes/stgdict.c
+++ b/Modules/_ctypes/stgdict.c
@@ -417,6 +417,8 @@
            that). Use 'B' for bytes. */
         stgdict->format = _ctypes_alloc_format_string(NULL, "B");
     }
+    if (stgdict->format == NULL)
+        return -1;
 
 #define realdict ((PyObject *)&stgdict->dict)
     for (i = 0; i < len; ++i) {
@@ -483,7 +485,7 @@
             char *fieldfmt = dict->format ? dict->format : "B";
             char *fieldname = _PyUnicode_AsString(name);
             char *ptr;
-            Py_ssize_t len; 
+            Py_ssize_t len;
             char *buf;
 
             if (fieldname == NULL)