[MCIAVI32] Media Player: Don't open empty files (#5063)

Opening an empty file in media player could cause a crash. CORE-18669
This commit is contained in:
Atharva Kulkarni 2023-02-18 16:03:58 +05:30 committed by GitHub
parent 874d317a71
commit ebc69d089f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -398,6 +398,13 @@ BOOL MCIAVI_GetInfo(WINE_MCIAVI* wma)
mmioAscend(wma->hFile, &mmckInfo, 0); mmioAscend(wma->hFile, &mmckInfo, 0);
} }
/* Empty file */
if (alb.numVideoFrames == 0) {
WARN("NumVideoFrames: %u, Empty or possibly corrupt video file");
return FALSE;
}
if (alb.numVideoFrames != wma->dwPlayableVideoFrames) { if (alb.numVideoFrames != wma->dwPlayableVideoFrames) {
WARN("AVI header says %d frames, we found %d video frames, reducing playable frames\n", WARN("AVI header says %d frames, we found %d video frames, reducing playable frames\n",
wma->dwPlayableVideoFrames, alb.numVideoFrames); wma->dwPlayableVideoFrames, alb.numVideoFrames);
@ -613,6 +620,11 @@ double MCIAVI_PaintFrame(WINE_MCIAVI* wma, HDC hDC)
if (wma->dwCurrVideoFrame != wma->dwCachedFrame) if (wma->dwCurrVideoFrame != wma->dwCachedFrame)
{ {
if (wma->dwCurrVideoFrame >= wma->dwPlayableVideoFrames) {
ERR("Invalid frame requested. Current : %u Total Playable %u\n", wma->dwCurrVideoFrame, wma->dwPlayableVideoFrames);
return 0;
}
if (!wma->lpVideoIndex[wma->dwCurrVideoFrame].dwOffset) if (!wma->lpVideoIndex[wma->dwCurrVideoFrame].dwOffset)
return 0; return 0;