#include <stdio.h>
#include <stdlib.h>
struct s {
int i;
};
int main(void){
struct s
*p1
= malloc(sizeof(struct s
)); p1->i = 42;
printf("(p1) before free: p->i = %d\n", p1
->i
); struct s
*p2
= malloc(sizeof(struct s
)); p2->i = 100;
// Trying to use the dangling pointer p1
printf("(p1) after free: p->i = %d\n", p1
->i
); printf("(: p2->i = %d\n", p2
->i
); }
I2luY2x1ZGUgPHN0ZGlvLmg+IAojaW5jbHVkZSA8c3RkbGliLmg+IApzdHJ1Y3QgcyB7IAogICAgaW50IGk7IAp9OyAKaW50IG1haW4odm9pZCl7IAogICAgc3RydWN0IHMgKnAxID0gbWFsbG9jKHNpemVvZihzdHJ1Y3QgcykpOyAKICAgIHAxLT5pID0gNDI7IAogICAgcHJpbnRmKCIocDEpIGJlZm9yZSBmcmVlOiBwLT5pID0gJWRcbiIsIHAxLT5pKTsgCiAgICBmcmVlKHAxKTsgCiAgICBzdHJ1Y3QgcyAqcDIgPSBtYWxsb2Moc2l6ZW9mKHN0cnVjdCBzKSk7IAogICAgcDItPmkgPSAxMDA7IAogICAgLy8gVHJ5aW5nIHRvIHVzZSB0aGUgZGFuZ2xpbmcgcG9pbnRlciBwMSAKICAgIHByaW50ZigiKHAxKSBhZnRlciBmcmVlOiBwLT5pID0gJWRcbiIsIHAxLT5pKTsgCiAgICBwcmludGYoIig6IHAyLT5pID0gJWRcbiIsIHAyLT5pKTsgCn0=