Fixed two crashes related to sharing badges with invalid share tokens.

Address the crashes described in #737.