#13842: check whether PyUnicode_FromString succeeded
diff --git a/Modules/_pickle.c b/Modules/_pickle.c
index 4212e7a..36aa9e0 100644
--- a/Modules/_pickle.c
+++ b/Modules/_pickle.c
@@ -2814,14 +2814,19 @@
 static int
 save_ellipsis(PicklerObject *self, PyObject *obj)
 {
-    return save_global(self, Py_Ellipsis, PyUnicode_FromString("Ellipsis"));
+    PyObject *str = PyUnicode_FromString("Ellipsis");
+    if (str == NULL)
+      return -1;
+    return save_global(self, Py_Ellipsis, str);
 }
 
 static int
 save_notimplemented(PicklerObject *self, PyObject *obj)
 {
-    return save_global(self, Py_NotImplemented,
-                       PyUnicode_FromString("NotImplemented"));
+    PyObject *str = PyUnicode_FromString("NotImplemented");
+    if (str == NULL)
+      return -1;
+    return save_global(self, Py_NotImplemented, str);
 }
 
 static int