bpo-35454: Fix miscellaneous minor issues in error handling. (GH-11077)


* bpo-35454: Fix miscellaneous minor issues in error handling.

* Fix a null pointer dereference.
(cherry picked from commit 8905fcc85a6fc3ac394bc89b0bbf40897e9497a6)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
diff --git a/Python/codecs.c b/Python/codecs.c
index eb3cd35..c315ae3 100644
--- a/Python/codecs.c
+++ b/Python/codecs.c
@@ -130,8 +130,10 @@
 
     /* Next, scan the search functions in order of registration */
     args = PyTuple_New(1);
-    if (args == NULL)
-        goto onError;
+    if (args == NULL) {
+        Py_DECREF(v);
+        return NULL;
+    }
     PyTuple_SET_ITEM(args,0,v);
 
     len = PyList_Size(interp->codec_search_path);