Valgrind: Invalid read of size 1

How to read this: Invalid read of size 1 Your program is trying to read one byte from somewhere that Valgrind doesn’t like. at 0x401569: main (:395) Where in the code this happens (clearly strcmp has been inlined) Address 0x0 is not stack’d malloc’d or (recently) free’d What the address it was reading – 0x0 … Read more

C free(): invalid pointer

You’re attempting to free something that isn’t a pointer to a “freeable” memory address. Just because something is an address doesn’t mean that you need to or should free it. There are two main types of memory you seem to be confusing – stack memory and heap memory. Stack memory lives in the live span of the function. … Read more

Uninitialised value was created by a stack allocation

The meaning of the error is essentially that you’re using a variable before you assign to it. The only variables this can possibly apply to are dd, mm, yy. This means that your sscanf call is not writing to all three of them. This will occur if you pass in a date that isn’t completely specified. Note that sscanf returns a value … Read more

How do I use valgrind to find memory leaks?

Try this: valgrind –leak-check=full -v ./your_program As long as valgrind is installed it will go through your program and tell you what’s wrong. It can give you pointers and approximate places where your leaks may be found. If you’re segfault’ing, try running it through gdb.