From 9dbc679444ef59a2e9f1185965d1f9d67f20b568 Mon Sep 17 00:00:00 2001 From: Changyeon Lee Date: Tue, 3 May 2016 20:47:47 +0900 Subject: [PATCH] Fix double free Change-Id: I0a1987af5eb0679187fb2bc398ca93bed95453e5 --- src/tdm.c | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/src/tdm.c b/src/tdm.c index acc9c05..ada9f29 100644 --- a/src/tdm.c +++ b/src/tdm.c @@ -90,30 +90,42 @@ tdm_display_find_output_stamp(tdm_private_display *private_display, static void _tdm_display_destroy_caps_pp(tdm_caps_pp *caps_pp) { - free(caps_pp->formats); + if (caps_pp->formats) + free(caps_pp->formats); + memset(caps_pp, 0, sizeof(tdm_caps_pp)); } static void _tdm_display_destroy_caps_capture(tdm_caps_capture *caps_capture) { - free(caps_capture->formats); + if (caps_capture->formats) + free(caps_capture->formats); + memset(caps_capture, 0, sizeof(tdm_caps_capture)); } static void _tdm_display_destroy_caps_layer(tdm_caps_layer *caps_layer) { - free(caps_layer->formats); - free(caps_layer->props); + if (caps_layer->formats) + free(caps_layer->formats); + + if (caps_layer->props) + free(caps_layer->props); + memset(caps_layer, 0, sizeof(tdm_caps_layer)); } static void _tdm_display_destroy_caps_output(tdm_caps_output *caps_output) { - free(caps_output->modes); - free(caps_output->props); + if (caps_output->modes) + free(caps_output->modes); + + if (caps_output->props) + free(caps_output->props); + memset(caps_output, 0, sizeof(tdm_caps_output)); } -- 2.7.4