display/libhwcomposer: fix potential memory leak
This changes fixes a memory leak, by freeing up the pipe alloc structure
everytime before parsing the current frame.
related-to-bug: 7301196
Change-Id: I23edefca71ec0209291be24ee9d629b4a80f0a25
Acked-by: Jeykumar Sankaran<jsanka@codeaurora.org>
Signed-off-by: Iliyan Malchev <malchev@google.com>
diff --git a/libhwcomposer/hwc_mdpcomp.cpp b/libhwcomposer/hwc_mdpcomp.cpp
index 4c4a9a0..213b74e 100644
--- a/libhwcomposer/hwc_mdpcomp.cpp
+++ b/libhwcomposer/hwc_mdpcomp.cpp
@@ -130,8 +130,10 @@
}
sCurrentFrame.count = 0;
- free(sCurrentFrame.pipe_layer);
- sCurrentFrame.pipe_layer = NULL;
+ if(sCurrentFrame.pipe_layer) {
+ free(sCurrentFrame.pipe_layer);
+ sCurrentFrame.pipe_layer = NULL;
+ }
//Reset MDP pipes
sPipeMgr.reset();
@@ -585,6 +587,11 @@
frame_info ¤t_frame = sCurrentFrame;
current_frame.count = 0;
+ if(current_frame.pipe_layer) {
+ free(current_frame.pipe_layer);
+ current_frame.pipe_layer = NULL;
+ }
+
if(!ctx) {
ALOGE("%s: invalid context", __FUNCTION__);
return -1;