Repository navigation
Conversation
… lookups The C.CString arguments in GetContactInfo and meowDecodeAttributedString were never freed, leaking len(identifier)+1 bytes per contact lookup and the base64-encoded attributedBody per decoded message. Fixes mautrix#239, fixes mautrix#240.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #239, fixes #240.
The
C.CStringarguments inGetContactInfo(contacts.go) andmeowDecodeAttributedString(attributedstring.go) were never freed:malloc'd memory that neither the Objective-C autorelease pool nor the Go GC will reclaim. Every contact lookup leakedlen(identifier)+1bytes, and every decodedattributedBodyleaked its base64 copy.This frees both strings with the standard
defer C.free(unsafe.Pointer(...))pattern and adds thestdlib.hinclude forfree. These are the only threeC.CStringcall sites in the package, so the audit is complete. The larger Objective-C side allocation growth noted in #239 (objects created without ARC) is intentionally out of scope, matching the reporter's own correction that-fobjc-arcdoesn't apply here.Verification:
gofmtclean; rootgo buildbehaves identically before and after the change (it fails only on the missinglibolmsystem dependency in my Linux environment, same as the clean baseline). I could not compile the darwin/cgo package locally (no macOS toolchain), so the change is reviewed mechanically — it follows the sameC.freepattern the reporter proposed and that cgo documents.AI assistance (various models) was used for this change.