Page MenuHomePhorge

Fix memory bugs
ClosedPublic

Authored by sicherha on May 24 2021, 3:06 PM.
Tags
None
Referenced Files
Unknown Object (File)
Thu, Mar 28, 1:34 AM
Unknown Object (File)
Sun, Mar 17, 10:08 PM
Unknown Object (File)
Sun, Mar 10, 9:50 PM
Unknown Object (File)
Sun, Mar 10, 9:50 PM
Unknown Object (File)
Sun, Mar 10, 9:43 PM
Unknown Object (File)
Sun, Mar 10, 9:38 PM
Unknown Object (File)
Feb 17 2024, 8:55 AM
Unknown Object (File)
Feb 14 2024, 12:44 AM
Subscribers

Details

Summary

This revision comprises a patch that fixes potential access to dangling
pointers, and one that plugs a bunch of memory leaks in the tests.

Fix dangling pointers

std::vector gives zero guarantees that pointers to its elements remain
valid when the vector's size changes. In particular, pushing new
elements into the vector may trigger reallocation of the underlying heap
area.

Consequently, Event::delegate() needs to ensure that any modifications
to the d->attendees vector are performed before pointers to its elements
are taken and collected.

Found with Valgrind.

Fix use-after-free bug

QByteArray::fromRawData() does not copy the contents of the source
buffer. If the resulting QByteArray object lives longer than the source
buffer, we run into use-after-free problems.

In this particular instance, the source data resides in a temporary
rvalue object.

Diff Detail

Repository
rLK libkolab
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

sicherha created this revision.

Looks reasonable, thanks for the patch.

Commit preferably as two separate patches.

This revision is now accepted and ready to land.May 24 2021, 6:41 PM

Hmm, does Arcanist offer a way to do fast-forward merges?

--strategy squash would squash my two commits into one.
--strategy merge would create a merge commit, which seems a bit excessive.

This revision was automatically updated to reflect the committed changes.