This commit is contained in:
Scarlett
2025-05-06 18:24:43 -04:00
parent a57aaf764a
commit 44f0e0f5af
3 changed files with 136 additions and 0 deletions

23
library/boundscheck.c Normal file
View 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);
}