🪃🪃
This commit is contained in:
23
library/boundscheck.c
Normal file
23
library/boundscheck.c
Normal file
@ -0,0 +1,23 @@
|
||||
#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);
|
||||
}
|
Reference in New Issue
Block a user