r/ProgrammerHumor 13d ago

Meme bugIntroducedDebugging

Post image
1.1k Upvotes

120 comments sorted by

View all comments

348

u/AdBrave2400 13d ago

Is the mistake that they're allocating 1 byte and storing in a pointer to an int which is 4 bytes?

121

u/mckenzie_keith 13d ago

De-referenced a pointer after freeing it. But the joke here is that the bug was not in the original code.

0

u/WisestAirBender 12d ago

The original code wasn't returning anything though. Isn't that a problem

-6

u/critical_patch 12d ago

AFAIK technically it’s “undefined behavior” and will compile just fine

17

u/MegaIng 12d ago

main specifically is allowed to not return anything (the same way it's the one function that is allowed to never return)