OSDN Git Service

Delete the output buffer when it is same as output_handle_
authorHeYue <yue.he@intel.com>
Fri, 22 Feb 2019 03:45:32 +0000 (11:45 +0800)
committerShaofeng Tang <shaofeng.tang@intel.com>
Mon, 25 Feb 2019 06:40:09 +0000 (14:40 +0800)
In ACRN virtualdisplay setoutput buffer, if the buffer is same as output_handle_
and output_handle_ is not null, delete the buffer to prevent memory leak.

Change-Id: I558f31aea3315481f3a00c1fef1202bb7eb124f1
Tracked-On: None
Tests: Compile sucess for ACRN and baremetal. System without issue.
Signed-off-by: HeYue <yue.he@intel.com>
common/display/virtualdisplay.cpp
common/display/virtualpanoramadisplay.cpp

index 3bdf779..c302248 100644 (file)
@@ -436,6 +436,8 @@ void VirtualDisplay::SetOutputBuffer(HWCNativeHandle buffer,
     if (output_handle_) {
       handler->CopyHandle(output_handle_, &handle_);
     }
+  } else {
+    delete buffer;
   }
 
   if (acquire_fence_ > 0) {
index e421ba2..899a22c 100644 (file)
@@ -412,6 +412,8 @@ void VirtualPanoramaDisplay::SetOutputBuffer(HWCNativeHandle buffer,
     if (output_handle_) {
       handler->CopyHandle(output_handle_, &handle_);
     }
+  } else {
+    delete buffer;
   }
 
   if (acquire_fence_ > 0) {