Skip to content

Fix type mismatch in PyXmlSec_ClearReplacedNodes for Python 3.13 compatibility #340

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 6, 2025

Conversation

haya4ux
Copy link
Contributor

@haya4ux haya4ux commented Feb 10, 2025

I’ve encountered a build failure with Python 3.13 caused by a type mismatch in the PyXmlSec_ClearReplacedNodes function. The issue arises because the variable elem is declared as a pointer-to-pointer (PyXmlSec_LxmlElementPtr*) instead of the correct pointer type (PyXmlSec_LxmlElementPtr). This misdeclaration leads to an incorrect argument being passed to Py_DECREF, which Python 3.13 now rejects due to its stricter type checking.

Changes:
• Changed the declaration of elem from PyXmlSec_LxmlElementPtr* elem; to PyXmlSec_LxmlElementPtr elem;
• Updated the cast accordingly in the call to PyXmlSec_elementFactory

Benefits:
• Resolves build errors on Python 3.13, ensuring compatibility with the latest Python release.
• Minimal and safe change that aligns with the intended design of the code.

Thank you for your continued work on this project. Please let me know if you have any questions or need further modifications.

@haya4ux
Copy link
Contributor Author

haya4ux commented Feb 10, 2025

related #335

@haya4ux
Copy link
Contributor Author

haya4ux commented Mar 1, 2025

Hi @jimjag, @mxamin, @bgaifullin and @jonathangreen,

Could you review this PR? My product relies on python3-saml and can’t upgrade to Python 3.13 due to a build failure in PyXmlSec_ClearReplacedNodes. This PR fixes the pointer mismatch that Python 3.13 flags. Thank you in advance!

For reference: PR Review by Claude 3.7

This PR corrects improper pointer handling in the node replacement cleanup logic. The fix properly aligns the variable type with its usage in the function.
I've verified that the fixed code correctly manages memory for replaced XML nodes during encryption/decryption operations, preventing potential use-after-free or memory leak scenarios. The original double-pointer declaration could have caused undefined behavior during Py_DECREF operations.
The change is localized to cleanup operations and won't affect the encryption/decryption logic itself. Safe to merge.

@ReedGraff
Copy link

Bump, have the same issue, same error, and am also relying on python3-saml.
Also need Python 3.13 to support another library

Copy link
Contributor

@jonathangreen jonathangreen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@haya4ux this fix looks reasonable to me!

I'm not much help getting it merged though, I've been contributing fixes for issues I've faced, but I'm not a maintainer on this repo.

@jimjag jimjag merged commit c9301a3 into xmlsec:master Mar 6, 2025
26 of 103 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants