September 2017
Beginner to intermediate
384 pages
8h 4m
English
The following example code demonstrates memory access to the already released memory locations:
#include <iostream>using namespace std;int main( ) { int *ptr = new int(); *ptr = 100; cout << "\nValue stored at pointer location is " << *ptr << endl; delete ptr; *ptr = 200; return 0;}
Let's compile the preceding program and learn how Valgrind reports the illegal memory access that attempts to access an already released memory location:
==118316== Memcheck, a memory error detector==118316== Copyright (C) 2002-2015, and GNU GPL'd, by Julian Seward et al.==118316== Using Valgrind-3.11.0 and LibVEX; rerun with -h for copyright info==118316== Command: ./a.out==118316== Value stored at ...