Logo
Never let a hardware engineer near your code.
  • Home
  • Hot
  • Random
  • Search

Browse

  • AI AI
  • AWS AWS
  • Agile Agile
  • Algorithms Algorithms
  • Android Android
  • Apple Apple
  • Backend Backend
  • Bash Bash
  • C++ C++
  • Cloud Cloud
  • Csharp Csharp
  • All Categories
As an Amazon Associate ProgrammerHumor.io earns from qualifying purchases.

HTTP 418: I'm a teapot

The server identifies as a teapot now and is on a tea break, brb

HTTP 418: I'm a teapot

The server identifies as a teapot now and is on a tea break, brb

Dangling-pointer Memes

Posts tagged with Dangling-pointer

Someone Said To Use The Stack Because Its Faster

C++ Programming Debugging
4 months ago 376.4K views 0 shares
Someone Said To Use The Stack Because Its Faster
So someone told you stack allocation is faster than heap allocation, and you took that advice a bit too literally. The function allocates a char array on the stack and then returns a pointer to it. Problem? That stack memory gets deallocated the moment the function returns, so you're handing back a pointer to memory that's already been reclaimed. It's like giving someone directions to a house that's been demolished. The comment "delicious segfault awaits" is chef's kiss accurate. Whoever tries to dereference that returned pointer is in for undefined behavior territory—could be garbage data, could be a crash, could be nothing at all until production when it spectacularly explodes. Stack allocation is faster, but returning stack-allocated memory is basically writing a check your program can't cash. Classic case of knowing just enough to be dangerous. Should've used malloc or just passed a buffer as a parameter. But hey, at least it compiles! (with warnings you definitely ignored)

Today's picks

WALI Single Monitor Mount for 13-34 inch Screens, Adjustable Single Monitors Arm, Regular Screen up to 32 inch, 26.4lbs, Computer Monitor Stand for Desk, VESA 75/100mm (GSMP001N), Black

WALI Single Monitor Mount for 13-34 inch Screens, Adjustable Single Monitors Arm, Regular Screen up to 32 inch, 26.4lbs, Computer Monitor Stand for Desk, VESA 75/100mm (GSMP001N), Black

Affiliate
$22.48
When Tech Jargon Ruins Your Dating Life

When Tech Jargon Ruins Your Dating Life

Databases
409.3K views 10 months ago
Low budget SOC

Low budget SOC

Programming
61.2K views 3 years ago