udscs: Fix memory ownership issues with udscs_read_callback
commit5dd6d2a88a966f1267ed0249a698f76723c063be
authorFrancois Gouget <fgouget@codeweavers.com>
Wed, 2 Nov 2016 15:36:15 +0000 (2 16:36 +0100)
committerChristophe Fergeau <cfergeau@redhat.com>
Wed, 9 Nov 2016 15:45:27 +0000 (9 16:45 +0100)
treef4d6cded00ed80616515fa51d0aa85fcf3d00447
parent08ff8d79daf44c29575d7bd39dcca68f4a3e87f5
udscs: Fix memory ownership issues with udscs_read_callback

Before this commit, udscs_read_callback is supposed to free the 'data'
buffer unless it calls udscs_destroy_connection(). It's currently not
doing this, causing a potential double free in error cases. The udscs
code would also leak the 'data' buffer if no udscs_read_callback is set.

This commit moves ownership of the 'data' buffer to the generic code
calling the udscs_read_callback and fixes the memory management of this
'data' buffer. As the only udscs_read_callback currently implemented is
not keeping pointers to 'data' after it returns, this should not cause
any issues.
src/udscs.c
src/udscs.h
src/vdagentd/vdagentd.c