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.
Para el ejemplo1.c, la resolución está comentada en el código, en los branches. La resolución del ejemplo2.c está sobre el main.