Issue #20434 Correct error handlin of _PyString_Resize and _PyBytes_Resize
diff --git a/Objects/bytearrayobject.c b/Objects/bytearrayobject.c
index 21c58ce..fd0ce7c 100644
--- a/Objects/bytearrayobject.c
+++ b/Objects/bytearrayobject.c
@@ -994,10 +994,8 @@
            *p++ = *quote_postfix++;
         }
         *p = '\0';
-        if (_PyString_Resize(&v, (p - PyString_AS_STRING(v)))) {
-            Py_DECREF(v);
-            return NULL;
-        }
+        /* v is cleared on error */
+        (void)_PyString_Resize(&v, (p - PyString_AS_STRING(v)));
         return v;
     }
 }
diff --git a/Objects/stringobject.c b/Objects/stringobject.c
index 83dab08..0b6d36c 100644
--- a/Objects/stringobject.c
+++ b/Objects/stringobject.c
@@ -748,8 +748,8 @@
                              UTF-8 bytes may follow. */
         }
     }
-    if (p-buf < newlen && _PyString_Resize(&v, p - buf))
-        goto failed;
+    if (p-buf < newlen)
+        _PyString_Resize(&v, p - buf); /* v is cleared on error */
     return v;
   failed:
     Py_DECREF(v);