23 lines
486 B
C
23 lines
486 B
C
#include <stdarg.h>
|
|
#include <stdlib.h>
|
|
#include <stdio.h>
|
|
|
|
int BoundsError(int d){
|
|
printf("You are trying to access memory that isn't yours.\n");
|
|
exit(1);
|
|
}
|
|
|
|
void BoundsCheck(int argc, void * start, ...){
|
|
va_list argptr;
|
|
va_start(argptr, start);
|
|
int index = 0;
|
|
while (argc){
|
|
argc--;
|
|
index = va_arg(argptr, int);
|
|
if(index > *(int*)start){
|
|
BoundsError(index);
|
|
}
|
|
start += sizeof(int);
|
|
}
|
|
va_end(argptr);
|
|
} |