bpo-34879: Fix a possible null pointer dereference in bytesobject.c (GH-9683)


formatfloat() was not checking if PyBytes_FromStringAndSize()
failed, which could lead to a null pointer dereference in
_PyBytes_FormatEx().
(cherry picked from commit 96c593279400693226d5a560c420ae0fcf1731b9)

Co-authored-by: Zackery Spytz <zspytz@gmail.com>
diff --git a/Objects/bytesobject.c b/Objects/bytesobject.c
index 82a7545..32ff5af 100644
--- a/Objects/bytesobject.c
+++ b/Objects/bytesobject.c
@@ -448,7 +448,7 @@
     result = PyBytes_FromStringAndSize(p, len);
     PyMem_Free(p);
     *p_result = result;
-    return str;
+    return result != NULL ? str : NULL;
 }
 
 static PyObject *