Source

pygame / src / font.c

Diff from to

src/font.c

         test = fopen (filename, "rb");
         if(!test)
         {
+            PyObject *tmp = NULL;
+
             if (!strcmp (filename, font_defaultname)) {
-                Py_DECREF (fileobj);
-                fileobj = font_resource (font_defaultname);
+                tmp = font_resource (font_defaultname);
             }
-            else {
-                Py_DECREF (fileobj);
-                fileobj = NULL;
-            }
-            if (!fileobj)
+            if (!tmp)
             {
-                PyErr_SetString (PyExc_IOError, "unable to read font filename");
+                PyErr_SetString (PyExc_IOError,
+                                 "unable to read font filename");
                 goto error;
             }
+            Py_DECREF (fileobj);
+            fileobj = tmp;
         }
         else
         {
     return 0;
 
 error:
-    Py_XDECREF (fileobj);
+    Py_DECREF (fileobj);
     return -1;
 }
 
         MODINIT_ERROR;
     }
     if (PyModule_AddObject (module, PYGAMEAPI_LOCAL_ENTRY, apiobj) == -1) {
+        Py_DECREF (apiobj);
         DECREF_MOD (module);
         MODINIT_ERROR;
     }