Guest User

Untitled

a guest
Jan 21st, 2018
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.51 KB | None | 0 0
  1. #include <iostream>
  2. #include <stdlib.h>
  3.  
  4.  
  5. int main(int argc, char **argv) {
  6. // waste
  7. int *foo = (int*)malloc(sizeof(int)*10);
  8. int *bar = (int*)malloc(sizeof(int)*10);
  9. int *baz;
  10.  
  11. // write past end of array
  12. bar[12] = 0;
  13. bar[0] = 0;
  14. if (baz)
  15. std::cout << "toto" << std::endl;
  16.  
  17. // uninitialized pointer
  18. std::cout << *baz << std::endl;
  19. std::cout << *bar << std::endl;
  20.  
  21. free(bar);
  22. std::cout << "Hello, world!" << std::endl;
  23. return 0;
  24.  
  25. }
Add Comment
Please, Sign In to add comment