fix memory leak 33/99933/2
authorBoram Park <boram1288.park@samsung.com>
Thu, 24 Nov 2016 10:41:46 +0000 (19:41 +0900)
committerSooChan Lim <sc1.lim@samsung.com>
Fri, 25 Nov 2016 07:53:01 +0000 (23:53 -0800)
Change-Id: Ia9795dc72428e976af48f789ab288abf7a0149c2

src/tdm_pp.c

index 1a61d7fa98ab1bdf82782c92607d90faff668d5f..93b787975f465a0263044caac8b91fe895e6e297 100644 (file)
@@ -266,6 +266,11 @@ tdm_pp_destroy_internal(tdm_private_pp *private_pp)
 
                LIST_FOR_EACH_ENTRY_SAFE(b, bb, &private_pp->pending_buffer_list, link) {
                        LIST_DEL(&b->link);
+                       _pthread_mutex_unlock(&private_display->lock);
+                       tdm_buffer_unref_backend(b->src);
+                       tdm_buffer_unref_backend(b->dst);
+                       _pthread_mutex_lock(&private_display->lock);
+                       free(b);
                }
        }
 
@@ -279,6 +284,7 @@ tdm_pp_destroy_internal(tdm_private_pp *private_pp)
                        tdm_buffer_unref_backend(b->src);
                        tdm_buffer_unref_backend(b->dst);
                        _pthread_mutex_lock(&private_display->lock);
+                       free(b);
                }
        }
 
@@ -458,12 +464,17 @@ tdm_pp_commit(tdm_pp *pp)
        TDM_WARNING_IF_FAIL(ret == TDM_ERROR_NONE);
 
        LIST_FOR_EACH_ENTRY_SAFE(b, bb, &commit_buffer_list, commit_link) {
+               LIST_DEL(&b->commit_link);
+
                if (!_tdm_pp_find_buffer(&private_pp->buffer_list, b))
                        continue;
 
-               LIST_DEL(&b->commit_link);
-
                if (ret != TDM_ERROR_NONE) {
+                       /* Not to call the user release handler when failed.
+                        * Do we have to call this function here really?
+                        * User better use set_done_handler to know when pp is done. Using
+                        * buffer_release_handler is not good.
+                        */
                        tdm_buffer_remove_release_handler_internal(b->src);
                        tdm_buffer_remove_release_handler_internal(b->dst);