diff options
author | Pekka Paalanen <pekka.paalanen@collabora.co.uk> | 2017-09-07 15:32:01 +0300 |
---|---|---|
committer | Pekka Paalanen <pekka.paalanen@collabora.co.uk> | 2018-02-12 16:49:34 +0200 |
commit | 46e4f97ab62a026968ca2d919a79bd2dd0a3c73a (patch) | |
tree | 942fd8eab4f3017ed06040671684ef8c20e0940b /libweston | |
parent | 383b3af5e1dc354c2594390a10bcd2ec494b5185 (diff) | |
download | weston-46e4f97ab62a026968ca2d919a79bd2dd0a3c73a.tar.gz |
compositor-drm: drm_property_info_free() must reset
This function needs to reset the structures to NULL, otherwise it is not
possible to re-use a once "freed" property info array.
Being able to re-use an array is useful when the memory allocation and
array lifetimes do not match. A specific example is drm_output that is
changed to allocate the CRTC on enable() and deallocate it on disable().
A drm_output might be enabled and disabled multiple times.
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Reviewed-by: Ian Ray <ian.ray@ge.com>
Reviewed-by: Daniel Stone <daniels@collabora.com>
Diffstat (limited to 'libweston')
-rw-r--r-- | libweston/compositor-drm.c | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/libweston/compositor-drm.c b/libweston/compositor-drm.c index 2f7247cf..268394bf 100644 --- a/libweston/compositor-drm.c +++ b/libweston/compositor-drm.c @@ -721,7 +721,9 @@ drm_property_info_populate(struct drm_backend *b, /** * Free DRM property information * - * Frees all memory associated with a DRM property info array. + * Frees all memory associated with a DRM property info array and zeroes + * it out, leaving it usable for a further drm_property_info_update() or + * drm_property_info_free(). * * @param info DRM property info array * @param num_props Number of entries in array to free @@ -733,6 +735,8 @@ drm_property_info_free(struct drm_property_info *info, int num_props) for (i = 0; i < num_props; i++) free(info[i].enum_values); + + memset(info, 0, sizeof(*info) * num_props); } static void |