iustin/pyxattr

Correct And Simplify Memory Handling in xattr_get

Closed this issue · 4 comments

ldo commented

I notice your xattr_get routine is missing a check for an error from the PyList_Append call.

While I was at it, I took the opportunity to rework the xattr_get logic to reduce the complexity of the control paths, eliminating all the gotos. As you can see from the enclosed patch, it becomes much easier to verify that everything will be be correctly disposed regardless of what errors might occur.

ldo-xattr_get.patch.txt

ldo commented

Sorry, noticed an omission in the patch. Update enclosed.

ldo-xattr_get.patch.txt

Hi,

Refactoring the way error handling is dome is, I consider, more a matter of taste. I'd like to discuss that separately from fixing an actual bug. Can you rebase and split the patch into bug-fix and rework-error-handling?

ldo commented

Code quality has nothing to do with “taste” (whatever that might mean).

Error handling methods, as long as correct, are a matter of style, and not of "quality". I'll fix the PyList_Append error checking, if you do want to send a pull request for the refactoring, please do that separately.