Use setenv() instead of the memory-leaky putenv() function.
Free allocated pixels after usage.
Free any existing NULL value before copying to it in copy_members().
De-allocate pointers after using them for testing purposes.
Properly free memory before allocation.
Avoid memory leaks.