Follow the instructions explained in the beginning of file ejemplo1.c for compiling with gcc and g++ (you can try also clang).
Find the memory errors presented in file ejemplo2 using gcc instrumentation option AddressSanitizer (ASan). Explain in this file each error.