Valgrind Tutorial - Part 5
Errors Occur Due to Invalid System Call Parameter can be found using valgrind
int main(void)
{
int *ptr;
ptr = malloc(10);
read(0, ptr, 100); /* Error: unaddressable bytes */
free(ptr);
return 0;
}
You can see the following code we allocated 10 bytes and we are trying to read 100 bytes from stdin(standard input).
Run the following commands
gcc -o app app.c -g
valgrind --tool=memcheck --leak-check=yes ./app
Comments
Post a Comment