on macOS:
listSnapshot was leaking in findStartupItemInList()
bitcoinAppUrl was leaking in [Get|Set]StartOnSystemStartup()
Fix memory leaks in qt/guiutil.cpp #11156
pull danra wants to merge 1 commits into bitcoin:master from danra:fix/qt-guiutil-memory-leaks changing 1 files +30 −11-
danra commented at 10:29 AM on August 26, 2017: contributor
-
9b348ff9eb
Fix memory leaks in qt/guiutil.cpp
on macOS: listSnapshot was leaking in findStartupItemInList() bitcoinAppUrl was leaking in [Get|Set]StartOnSystemStartup()
- laanwj added the label GUI on Aug 26, 2017
- laanwj added the label MacOSX on Aug 26, 2017
-
promag commented at 11:22 AM on August 28, 2017: member
CFArrayGetCountdereferenceslistSnapshotand if it'snullptrthen it crashes, so how have you tested this? -
danra commented at 8:26 PM on August 28, 2017: contributor
@promag Not sure I understand the question, do you mean
+ if (listSnapshot == nullptr) { + return nullptr; + }added at 784-786?
This is just for safety, it's not really expected for
listSnapshotto benullptr. I think it makes sense to add this safety in the context of not doingCFReleaseonnullptrat the end. You're right that even without the added lines above, in case oflistSnapshot == nullptrthere will probably be a crash even before we get to theCFRelease. Still, seems cleaner to me.Also, in the unlikely case that
listSnapshotis set tonullptr, we will returnnullptrinstead of crashing, which is probably nicer behavior anyway. (though, it's up to the caller whether it itself would crash or not) -
ryanofsky commented at 6:17 PM on August 29, 2017: member
utACK 9b348ff9eb75e04249dfa873a34e0d1a31993b9c. Seems right, though maybe it would be simpler with an RAII helper class:
struct CFReleaser { CFReleaser(CFTypeRef cf) m_cf(cf) {} ~CFReleaser() { if (m_cf) CFRelease(m_cf); } CFTypeRef m_cf; }; -
danra commented at 7:39 AM on August 30, 2017: contributor
@ryanofsky I agree, just didn't want to do two things at once - introduce such a class as well as fix problematic code. Once this is merged I'm for doing a separate pull requests with a commit that introduces such a class, followed by commits which make use of it.
-
jonasschnelli commented at 4:35 PM on September 3, 2017: contributor
utACK 9b348ff9eb75e04249dfa873a34e0d1a31993b9c. I think we should also get rid of the OSX Growl support.
-
laanwj commented at 10:18 PM on September 5, 2017: member
I really like the idea of using a RAII class here. Much easier to check whether all possible exit paths are covered, and exception-safety comes for free.
-
jonasschnelli commented at 5:01 PM on September 7, 2017: contributor
I agree an RAII approach would be much better. But until someone comes up with an RAII for that pure OSX stuff, I think this is an valid improvement.
Tested ACK 9b348ff9eb75e04249dfa873a34e0d1a31993b9c. Could not find any leaks with macOS instruments (leak detector) during notifications.
- jonasschnelli merged this on Sep 7, 2017
- jonasschnelli closed this on Sep 7, 2017
- jonasschnelli referenced this in commit a3624ddb1a on Sep 7, 2017
- PastaPastaPasta referenced this in commit 8836221f78 on Sep 23, 2019
- PastaPastaPasta referenced this in commit 7eeaa67b4c on Sep 24, 2019
- PastaPastaPasta referenced this in commit 028a2542d1 on Nov 19, 2019
- PastaPastaPasta referenced this in commit 7377fc8c14 on Nov 21, 2019
- PastaPastaPasta referenced this in commit 3e9d53d987 on Dec 9, 2019
- PastaPastaPasta referenced this in commit b1a7734306 on Jan 1, 2020
- PastaPastaPasta referenced this in commit c0a501a8ce on Jan 2, 2020
- PastaPastaPasta referenced this in commit 633acc1c7c on Jan 2, 2020
- PastaPastaPasta referenced this in commit 40c9708fe6 on Jan 2, 2020
- PastaPastaPasta referenced this in commit ce464a97ce on Jan 2, 2020
- PastaPastaPasta referenced this in commit 6c420e87ac on Jan 2, 2020
- PastaPastaPasta referenced this in commit 9044d5315b on Jan 3, 2020
- ckti referenced this in commit c58b1a695e on Mar 28, 2021
- furszy referenced this in commit 4a6d1000ed on May 11, 2021
- DrahtBot locked this on Sep 8, 2021