Delete errmsg if isn't NULL
Merge pull request #21 from kesla/delete-errmsg

Delete errmsg if isn't NULL