agent: Fix a leak in nice_output_stream_write() with a NULL cancellable
authorPhilip Withnall <philip.withnall@collabora.co.uk>
Tue, 15 Apr 2014 17:06:44 +0000 (18:06 +0100)
committerPhilip Withnall <philip.withnall@collabora.co.uk>
Tue, 15 Apr 2014 17:09:08 +0000 (18:09 +0100)
commit6c574fb308f490f4d179c7fd20ca43e0918039c2
tree89e424fdc51d216b3fe8846673f992f3032e0884
parent1c4aeec310b22e7f93d4386da1582f79181e57cd
agent: Fix a leak in nice_output_stream_write() with a NULL cancellable

If @cancellable is NULL in a call to nice_output_stream_write(), the
WriteData struct is created with a reference count of 4, but only two
operations are scheduled which will result in its reference count being
decremented. The third operation is only scheduled if @cancellable is
non-NULL (and the final reference is dropped unconditionally at the end
of the function).

Fix this by properly implementing reference counting for WriteData,
rather than hard-coding the expected number of references in a fragile
and unmaintainable way.
agent/outputstream.c