Valgrind won't detect buffer overflow. From Valgrind Tutorial What valgrind is NOT Although valgrind is an extremely useful program, it will not miraculously tell you about every memory bug in your program. There are several limitations that you should keep in mind. It does not do bounds checking on stack/static arrays ..