From: Behdad Esfahbod Date: Mon, 16 Nov 2009 23:29:26 +0000 (-0500) Subject: [lang] Fix serializing LangSet from older versions X-Git-Tag: 2.8.0~14 X-Git-Url: https://git.wh0rd.org/?a=commitdiff_plain;h=a3b2426819836ab2454c6a7bad27c382f4a245bf;p=fontconfig.git [lang] Fix serializing LangSet from older versions --- diff --git a/src/fclang.c b/src/fclang.c index 61c4da6..1d62c4e 100644 --- a/src/fclang.c +++ b/src/fclang.c @@ -537,9 +537,10 @@ FcChar32 FcLangSetHash (const FcLangSet *ls) { FcChar32 h = 0; - int i; + int i, count; - for (i = 0; i < ls->map_size; i++) + count = FC_MIN (ls->map_size, NUM_LANG_SET_MAP); + for (i = 0; i < count; i++) h ^= ls->map[i]; if (ls->extra) h ^= ls->extra->num; @@ -777,7 +778,9 @@ FcLangSetSerialize(FcSerialize *serialize, const FcLangSet *l) if (!l_serialize) return NULL; - *l_serialize = *l; + memset (l_serialize->map, '\0', sizeof (l_serialize->map)); + memcpy (l_serialize->map, l->map, FC_MIN (sizeof (l_serialize->map), l->map_size * sizeof (l->map[0]))); + l_serialize->map_size = NUM_LANG_SET_MAP; l_serialize->extra = NULL; /* We don't serialize ls->extra */ return l_serialize; }