X-Git-Url: https://git.wh0rd.org/?a=blobdiff_plain;f=src%2Ffclang.c;h=1d62c4e3f52960852614ce8ff4c9e8d4ca8305f1;hb=a3b2426819836ab2454c6a7bad27c382f4a245bf;hp=0f2f963d0dae0fcbc63ced64736c5a430e903294;hpb=1f4e6fecde22fd4ce8336b01a5c32c533fcb8bac;p=fontconfig.git diff --git a/src/fclang.c b/src/fclang.c index 0f2f963..1d62c4e 100644 --- a/src/fclang.c +++ b/src/fclang.c @@ -39,7 +39,7 @@ typedef struct { struct _FcLangSet { FcStrSet *extra; - int map_size; + FcChar32 map_size; FcChar32 map[NUM_LANG_SET_MAP]; }; @@ -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; }