Skip to content

Commit

Permalink
Properly handle module refcount during init errors
Browse files Browse the repository at this point in the history
Together with the commit in #36, this should fix issue #35,
  • Loading branch information
iustin authored Oct 10, 2022
1 parent 5234c00 commit 98919e1
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions xattr.c
Original file line number Diff line number Diff line change
Expand Up @@ -1206,6 +1206,10 @@ PyInit_xattr(void)
goto err_out;
if((ns_user = PyBytes_FromString("user")) == NULL)
goto err_out;

/* Add the new objects to the module */
/* TODO: after switching to min 3.10, use the *Ref version, and simplify
the error handling. */
if(PyModule_AddObject(m, "NS_SECURITY", ns_security) < 0)
goto err_out;
ns_security = NULL;
Expand All @@ -1226,5 +1230,6 @@ PyInit_xattr(void)
Py_XDECREF(ns_trusted);
Py_XDECREF(ns_system);
Py_XDECREF(ns_security);
Py_DECREF(m);
INITERROR;
}

0 comments on commit 98919e1

Please sign in to comment.