Skip to content

Commit

Permalink
Fix for memory leak when updating stream sources
Browse files Browse the repository at this point in the history
  • Loading branch information
sskodje committed Aug 11, 2024
1 parent bcad5cf commit fe00a9e
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions ScreenRecorderLib/Recorder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -776,6 +776,7 @@ HRESULT Recorder::CreateOrUpdateNativeRecordingSource(_In_ RecordingSourceBase^
VideoRecordingSource^ videoSource = (VideoRecordingSource^)managedSource;
pNativeSource->Type = RecordingSourceType::Video;
if (videoSource->SourceStream) {
SafeRelease(&pNativeSource->SourceStream);
pNativeSource->SourceStream = new ManagedIStream(videoSource->SourceStream);
hr = S_OK;
}
Expand All @@ -788,6 +789,7 @@ HRESULT Recorder::CreateOrUpdateNativeRecordingSource(_In_ RecordingSourceBase^
ImageRecordingSource^ imageSource = (ImageRecordingSource^)managedSource;
pNativeSource->Type = RecordingSourceType::Picture;
if (imageSource->SourceStream) {
SafeRelease(&pNativeSource->SourceStream);
pNativeSource->SourceStream = new ManagedIStream(imageSource->SourceStream);
hr = S_OK;
}
Expand Down Expand Up @@ -826,6 +828,7 @@ HRESULT Recorder::CreateOrUpdateNativeRecordingOverlay(_In_ RecordingOverlayBase
ImageOverlay^ pictureOverlay = (ImageOverlay^)managedOverlay;
pNativeOverlay->Type = RecordingSourceType::Picture;
if (pictureOverlay->SourceStream) {
SafeRelease(&pNativeOverlay->SourceStream);
pNativeOverlay->SourceStream = new ManagedIStream(pictureOverlay->SourceStream);
hr = S_OK;
}
Expand All @@ -838,6 +841,7 @@ HRESULT Recorder::CreateOrUpdateNativeRecordingOverlay(_In_ RecordingOverlayBase
VideoOverlay^ videoOverlay = (VideoOverlay^)managedOverlay;
pNativeOverlay->Type = RecordingSourceType::Video;
if (videoOverlay->SourceStream) {
SafeRelease(&pNativeOverlay->SourceStream);
pNativeOverlay->SourceStream = new ManagedIStream(videoOverlay->SourceStream);
hr = S_OK;
}
Expand Down

0 comments on commit fe00a9e

Please sign in to comment.