Commit 790771b1 authored by Paul Eggert's avatar Paul Eggert
Browse files

* font.c (font_score): Avoid potential overflow in diff calculation.

parent 78834453
2011-04-03 Paul Eggert <eggert@cs.ucla.edu>
* font.c (font_find_for_lface, Ffont_get_glyphs): Remove unused vars.
(font_score): Avoid potential overflow in diff calculation.
* fns.c (substring_both): Remove var that is set but not used.
(sxhash): Redo loop for clarity and to avoid wraparound warning.
......@@ -2076,12 +2076,11 @@ font_score (Lisp_Object entity, Lisp_Object *spec_prop)
for (i = FONT_WEIGHT_INDEX; i <= FONT_WIDTH_INDEX; i++)
if (! NILP (spec_prop[i]) && ! EQ (AREF (entity, i), spec_prop[i]))
{
int diff = (XINT (AREF (entity, i)) >> 8) - (XINT (spec_prop[i]) >> 8);
EMACS_INT diff = ((XINT (AREF (entity, i)) >> 8)
- (XINT (spec_prop[i]) >> 8));
if (diff < 0)
diff = - diff;
if (diff > 0)
score |= min (diff, 127) << sort_shift_bits[i];
score |= min (diff, 127) << sort_shift_bits[i];
}
/* Score the size. Maximum difference is 127. */
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment