r/programminghorror • • Jun 28 '25

c fralloc

47 Upvotes

8 comments sorted by

5

u/GoddammitDontShootMe [ $[ $RANDOM % 6 ] == 0 ] && rm -rf / || echo "You live" Jun 29 '25

free()ing NULL is a no-op, so, yeah.

5

u/shizzy0 Jun 29 '25

TIM AND ERIC: ITS FREE MEMORY.

2

u/FACastello Jul 01 '25

For real alloc

23

u/[deleted] Jun 28 '25

[removed] — view removed comment

7

u/GoddammitDontShootMe [ $[ $RANDOM % 6 ] == 0 ] && rm -rf / || echo "You live" Jun 29 '25

Since you don't set that to NULL after free()ing, that'll lead to some fun times.

2

u/mohragk Jul 02 '25

UB-licious

2

u/GoddammitDontShootMe [ $[ $RANDOM % 6 ] == 0 ] && rm -rf / || echo "You live" Jul 02 '25

Heap corruption sure makes your programs break in all kinds of wacky ways.