Skip to content
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

Fix segmentation faults when errors occur while handling unserialisable objects #531

Merged
merged 1 commit into from Apr 18, 2022

Conversation

JustAnotherArchivist
Copy link
Collaborator

Errors during __repr__ itself as well as ones during the conversion to a bytes object were not handled, resulting in NULL pointer dereferencing.

Cf. #382

Errors during `__repr__` itself as well as ones during the conversion to a bytes object were not handled, resulting in NULL pointer dereferencing.

Cf. ultrajson#382
@codecov-commenter
Copy link

Codecov Report

Merging #531 (5a52c12) into main (7799498) will increase coverage by 0.04%.
The diff coverage is 100.00%.

@@            Coverage Diff             @@
##             main     #531      +/-   ##
==========================================
+ Coverage   91.71%   91.75%   +0.04%     
==========================================
  Files           6        6              
  Lines        1810     1819       +9     
==========================================
+ Hits         1660     1669       +9     
  Misses        150      150              
Impacted Files Coverage Δ
python/objToJSON.c 90.43% <100.00%> (+0.06%) ⬆️
tests/test_ujson.py 99.60% <100.00%> (+<0.01%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 7799498...5a52c12. Read the comment docs.

@JustAnotherArchivist
Copy link
Collaborator Author

To repeat my comment from #382: "~E~" as the error handler was, as far as I can tell, never a thing. With the "strict" error handler, this behaves much more reasonable. If __repr__ returns an invalid strict UTF-8 string (like one containing a surrogate escape), this is bubbling up now. Note that the json standard library instead raises a TypeError like 'Object of type A is not JSON serializable', but doing this from C is more involved, and I'm not sure it's the right thing to do anyway as it can hide the actual exception that caused things to blow up.

@JustAnotherArchivist JustAnotherArchivist changed the title Fix segmentation faults when handling unserialisable objects Fix segmentation faults when errors occur while handling unserialisable objects Apr 17, 2022
@bwoodsend bwoodsend added the changelog: Fixed For any bug fixes label Apr 18, 2022
@bwoodsend bwoodsend merged commit b3f8754 into ultrajson:main Apr 18, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
changelog: Fixed For any bug fixes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants