Update PWM_lib.c

Added omitted free(buff) call. Change from sprintf to snprintf for sanity check. Thanks to AMontefusco. 
Added null pointer malloc check.