浏览代码

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 年之前
父节点
当前提交
595de46e9d
共有 1 个文件被更改,包括 6 次插入4 次删除
  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;