Browse Source

decklink: Fix crash (null pointer dereference)

This is my fault; I made an idiotic assumption about the data and it
ended up causing the plugin to crash.  This is definitely one of my more
embarrassing moments.
jp9000 10 years ago
parent
commit
595de46e9d
1 changed files with 6 additions and 4 deletions
  1. 6 4
      plugins/decklink/decklink-device-instance.cpp

+ 6 - 4
plugins/decklink/decklink-device-instance.cpp

@@ -140,12 +140,14 @@ HRESULT STDMETHODCALLTYPE DeckLinkDeviceInstance::VideoInputFrameArrived(
 	BMDTimeValue videoDur = 0;
 	BMDTimeValue audioTS = 0;
 
-	videoFrame->GetStreamTime(&videoTS, &videoDur, TIME_BASE);
-	audioPacket->GetPacketTime(&audioTS, TIME_BASE);
+	if (videoFrame)
+		videoFrame->GetStreamTime(&videoTS, &videoDur, TIME_BASE);
+	if (audioPacket)
+		audioPacket->GetPacketTime(&audioTS, TIME_BASE);
 
-	if (videoTS >= 0)
+	if (videoFrame && videoTS >= 0)
 		HandleVideoFrame(videoFrame, (uint64_t)videoTS);
-	if (audioTS >= 0)
+	if (audioPacket && audioTS >= 0)
 		HandleAudioPacket(audioPacket, (uint64_t)audioTS);
 
 	return S_OK;