shithub: neatroff

Download patch

ref: 82f77e914154d4147c149f54c72bc85eef3fcc44
parent: 603ad1a37d08437b3a51a0f62b88834c4a7611ab
author: Ali Gholami Rudi <ali@rudi.ir>
date: Thu Nov 27 03:41:22 EST 2014

font: ignore bad keys in iset_get() and iset_put()

This should handle rules with missing glyphs. Reported by Dirk-Wilhelm
Peters <peters@schwertfisch.de>.

--- a/font.c
+++ b/font.c
@@ -704,12 +704,12 @@
 
 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]));