Fix crash in Qt CDL when cdloggerVideoDataSize is zero.

This commit is contained in:
harry 2023-02-19 15:22:34 -05:00
parent 6b73e91c38
commit 56c0d30f83
1 changed files with 12 additions and 2 deletions

View File

@ -790,7 +790,14 @@ void InitCDLog(void)
if (!CHRram[0] || (CHRptr[0] == PRGptr[0]))
{ // Some kind of workaround for my OneBus VRAM hack, will remove it if I find another solution for that
cdloggerVideoDataSize = CHRsize[0];
cdloggervdata = (unsigned char *)malloc(cdloggerVideoDataSize);
if (cdloggerVideoDataSize > 0)
{
cdloggervdata = (unsigned char *)malloc(cdloggerVideoDataSize);
}
else
{
cdloggervdata = nullptr;
}
}
else
{
@ -832,7 +839,10 @@ void ResetCDLog(void)
if (GameInfo->type != GIT_NSF)
{
undefinedvromcount = 8192;
memset(cdloggervdata, 0, 8192);
if (cdloggervdata != NULL)
{
memset(cdloggervdata, 0, 8192);
}
}
}
FCEU_WRAPPER_UNLOCK();