sim65 cycles 32-bit range fix
long is 64-bit on some platforms, making this inconsistent, added range check to catch overflow. reduced tests requesting 5 billion cycles to 2^32-1 so they can fun on 32-bit long sim65.
This commit is contained in:
@@ -36,6 +36,7 @@
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <errno.h>
|
||||
#include <limits.h>
|
||||
|
||||
/* common */
|
||||
#include "abend.h"
|
||||
@@ -140,6 +141,10 @@ static void OptQuitXIns (const char* Opt attribute ((unused)),
|
||||
/* quit after MaxCycles cycles */
|
||||
{
|
||||
MaxCycles = strtoul(Arg, NULL, 0);
|
||||
/* Guard against overflow. */
|
||||
if (MaxCycles == ULONG_MAX && errno == ERANGE) {
|
||||
Error("'-x parameter out of range. Max: %lu",ULONG_MAX);
|
||||
}
|
||||
}
|
||||
|
||||
static unsigned char ReadProgramFile (void)
|
||||
|
||||
Reference in New Issue
Block a user