fix memory leak with format, meaning

check just before return at end of function