c++ - Invalid read of size 1 in tetris using valgrind -
i trying write tetris dynamic 2d array of rows , cols named data; make function called edit_2darray duplicate original 2d array , make each column longer, , rest fill space; ==21909== invalid read of size 1 ==21909== @ 0x100002c0a: tetris::print() const (main.cpp:300) ==21909== 0x1000011cb: test_example() (main.cpp:59) ==21909== 0x100001053: main (main.cpp:36) ==21909== address 0x10080a9c1 1 bytes inside block of size 2 free'd ==21909== @ 0x1000132f7: free (in /usr/local/cellar/valgrind/3.11.0/lib/valgrind/vgpreload_memcheck-amd64-darwin.so) ==21909== 0x100005188: tetris::edit_2darray(int, int) (tetris.cpp:214) ==21909== 0x1000056ec: tetris::add_piece(char, int, int) (tetris.cpp:279) ==21909== 0x10000118f: test_example() (main.cpp:57) ==21909== 0x100001053: main (main.cpp:36) ==21909== block alloc'd @ ==21909== @ 0x100012ebb: malloc (in /usr/local/cellar/valgrind/3.11.0/lib/valgrind/vgpreload_memcheck-amd64-darwin.so) ==21909== 0x10005743d:...