[cmap] Check GID before adding ranges in format 4 & 12

Fixes https://github.com/harfbuzz/harfbuzz/issues/2031
3 files changed