ws: fixed #668. Freed the malloc'd memory when it is no longer needed.

Fixed it.