You have a memory leak here. You malloc() the memory but it is never released. It is a small leak but still not good!