Skip to content

Instantly share code, notes, and snippets.

@chrisyco
Created April 8, 2012 06:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save chrisyco/2335298 to your computer and use it in GitHub Desktop.
Save chrisyco/2335298 to your computer and use it in GitHub Desktop.
Memory leak in 10 lines of code
#include <stdlib.h>
#include <unistd.h>
int main() {
size_t sz = sysconf(_SC_PAGESIZE);
for (;;) {
char *leak = malloc(sz);
leak[0] = 'a';
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment