Subset of C language with tree interpreter and bytecode compiler + VM.
Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.
 
 

18 řádky
476 B

// use-after-free
#include <stdlib.h>
#include <stdio.h>
#include <assert.h>
int main() {
int *ptr = (int *)malloc(sizeof(*ptr));
assert(ptr != 0);
*ptr = 42;
printf("%p %d\n", ptr, *ptr);
free(ptr);
printf("%p %d\n", ptr, *ptr); // use after free
// the following usully causes a SEGV in the interpreter because the store corrupts GC memory
*ptr = 43; // use after free
printf("%p %d\n", ptr, *ptr); // use after free
return 0;
}