From 82f77e914154d4147c149f54c72bc85eef3fcc44 Mon Sep 17 00:00:00 2001 From: Ali Gholami Rudi Date: Thu, 27 Nov 2014 08:41:22 +0330 Subject: [PATCH] font: ignore bad keys in iset_get() and iset_put() This should handle rules with missing glyphs. Reported by Dirk-Wilhelm Peters . --- font.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/font.c b/font.c index 097a6d8..6f64323 100644 --- a/font.c +++ b/font.c @@ -704,12 +704,12 @@ static void iset_free(struct iset *iset) static int *iset_get(struct iset *iset, int key) { - return iset->set[key]; + return key >= 0 && key < iset->keycnt ? iset->set[key] : NULL; } static void iset_put(struct iset *iset, int key, int ent) { - if (iset->len[key] + 1 >= iset->sz[key]) { + if (key >= 0 && key < iset->keycnt && iset->len[key] + 1 >= iset->sz[key]) { int olen = iset->sz[key]; int nlen = iset->sz[key] * 2 + 8; void *nset = malloc(nlen * sizeof(iset->set[key][0])); -- 2.11.4.GIT