places: check string length before accessing it

(integrated from trunk branch change f19ec1e by Todd Whiteman <toddw@activestate.com>)