mirror of
https://github.com/AppleWin/AppleWin.git
synced 2025-02-07 16:31:00 +00:00
Coverity SA: Fixed the 2 new Impact=High issues:
. CID 1499553: UNINIT . CID 1499560: OVERRUN (out of bounds access in CmdBookmarkAdd) Fixed bug in CmdBookmarkClear() too.
This commit is contained in:
parent
38347cfba8
commit
d6a2339ff0
@ -565,78 +565,47 @@ Update_t CmdBookmark (int nArgs)
|
|||||||
//===========================================================================
|
//===========================================================================
|
||||||
Update_t CmdBookmarkAdd (int nArgs )
|
Update_t CmdBookmarkAdd (int nArgs )
|
||||||
{
|
{
|
||||||
// BMA [address]
|
// BMA address
|
||||||
// BMA # address
|
// BMA # address ; where # is [0...9]
|
||||||
if (! nArgs)
|
if (! nArgs)
|
||||||
{
|
{
|
||||||
return CmdZeroPageList( 0 );
|
return CmdBookmarkList( 0 );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int iBookmark = 0;
|
||||||
|
|
||||||
int iArg = 1;
|
int iArg = 1;
|
||||||
int iBookmark = NO_6502_TARGET;
|
|
||||||
|
|
||||||
if (nArgs > 1)
|
if (nArgs > 1)
|
||||||
{
|
{
|
||||||
iBookmark = g_aArgs[ 1 ].nValue;
|
iBookmark = g_aArgs[ iArg ].nValue;
|
||||||
iArg++;
|
iArg++;
|
||||||
}
|
}
|
||||||
|
else
|
||||||
bool bAdded = false;
|
|
||||||
for (; iArg <= nArgs; iArg++ )
|
|
||||||
{
|
{
|
||||||
WORD nAddress = g_aArgs[ iArg ].nValue;
|
while ((iBookmark < MAX_BOOKMARKS) && g_aBookmarks[iBookmark].bSet)
|
||||||
|
iBookmark++;
|
||||||
if (iBookmark == NO_6502_TARGET)
|
|
||||||
{
|
|
||||||
iBookmark = 0;
|
|
||||||
while ((iBookmark < MAX_BOOKMARKS) && (g_aBookmarks[iBookmark].bSet))
|
|
||||||
{
|
|
||||||
iBookmark++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if ((iBookmark >= MAX_BOOKMARKS) && !bAdded)
|
|
||||||
{
|
|
||||||
char sText[ CONSOLE_WIDTH ];
|
|
||||||
sprintf( sText, "All bookmarks are currently in use. (Max: %d)", MAX_BOOKMARKS );
|
|
||||||
ConsoleDisplayPush( sText );
|
|
||||||
return ConsoleUpdate();
|
|
||||||
}
|
|
||||||
|
|
||||||
// 2.9.0.16 Fixed: Replacing an existing bookmark incorrectly increased the total bookmark count.
|
|
||||||
int nOldBookmark = Bookmark_Find( nAddress );
|
|
||||||
if (nOldBookmark)
|
|
||||||
{
|
|
||||||
_Bookmark_Del( nAddress );
|
|
||||||
}
|
|
||||||
|
|
||||||
// 2.9.0.17 Fixed: If all bookmarks were used then setting a new one wouldn't update an existing one to the new address.
|
|
||||||
if (g_aBookmarks[ iBookmark ].bSet)
|
|
||||||
{
|
|
||||||
g_aBookmarks[ iBookmark ].nAddress = nAddress;
|
|
||||||
bAdded = true;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
if (g_nBookmarks < MAX_BOOKMARKS)
|
|
||||||
{
|
|
||||||
bAdded = _Bookmark_Add( iBookmark, nAddress );
|
|
||||||
iBookmark++;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
WORD nAddress = g_aArgs[ iArg ].nValue;
|
||||||
|
|
||||||
|
if (iBookmark >= MAX_BOOKMARKS)
|
||||||
|
{
|
||||||
|
char sText[ CONSOLE_WIDTH ];
|
||||||
|
sprintf( sText, "All bookmarks are currently in use. (Max: %d)", MAX_BOOKMARKS );
|
||||||
|
ConsoleDisplayPush( sText );
|
||||||
|
return ConsoleUpdate();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Bookmark_Find( nAddress ))
|
||||||
|
_Bookmark_Del( nAddress );
|
||||||
|
|
||||||
|
bool bAdded = _Bookmark_Add( iBookmark, nAddress );
|
||||||
if (!bAdded)
|
if (!bAdded)
|
||||||
goto _Help;
|
return Help_Arg_1( CMD_BOOKMARK_ADD );
|
||||||
|
|
||||||
return UPDATE_DISASM | ConsoleUpdate();
|
return UPDATE_DISASM | ConsoleUpdate();
|
||||||
|
|
||||||
_Help:
|
|
||||||
return Help_Arg_1( CMD_BOOKMARK_ADD );
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//===========================================================================
|
//===========================================================================
|
||||||
Update_t CmdBookmarkClear (int nArgs)
|
Update_t CmdBookmarkClear (int nArgs)
|
||||||
{
|
{
|
||||||
@ -653,7 +622,7 @@ Update_t CmdBookmarkClear (int nArgs)
|
|||||||
|
|
||||||
iBookmark = g_aArgs[ iArg ].nValue;
|
iBookmark = g_aArgs[ iArg ].nValue;
|
||||||
if (g_aBookmarks[ iBookmark ].bSet)
|
if (g_aBookmarks[ iBookmark ].bSet)
|
||||||
g_aBookmarks[ iBookmark ].bSet = false;
|
_Bookmark_Del(g_aBookmarks[ iBookmark ].nAddress);
|
||||||
}
|
}
|
||||||
|
|
||||||
return UPDATE_DISASM;
|
return UPDATE_DISASM;
|
||||||
|
@ -1826,8 +1826,7 @@ static BYTE __stdcall MB_Write(WORD PC, WORD nAddr, BYTE bWrite, BYTE nValue, UL
|
|||||||
if(nMB != 0) // Slot4 only
|
if(nMB != 0) // Slot4 only
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
int CS;
|
int CS = 0;
|
||||||
|
|
||||||
if (g_phasorMode == PH_Mockingboard)
|
if (g_phasorMode == PH_Mockingboard)
|
||||||
CS = ( ( nAddr & 0x80 ) >> 7 ) + 1; // 1 or 2
|
CS = ( ( nAddr & 0x80 ) >> 7 ) + 1; // 1 or 2
|
||||||
else if (g_phasorMode == PH_Phasor)
|
else if (g_phasorMode == PH_Phasor)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user