Fixing bug where tryign to call strlen() after memory is free'd.