set msg to NULL when it is free