From: Paul Eggert Date: Tue, 21 Jun 2011 06:47:52 +0000 (-0700) Subject: * font.c (font_intern_prop): Don't use string_to_number, since the string isn't null... X-Git-Tag: emacs-pretest-24.0.90~104^2~473^2~9 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=da3f12b238fbbf4632bdf137b08446b1ee655faf;p=emacs.git * font.c (font_intern_prop): Don't use string_to_number, since the string isn't null-terminated. --- diff --git a/src/font.c b/src/font.c index cc57af12141..dfc636e3313 100644 --- a/src/font.c +++ b/src/font.c @@ -241,17 +241,25 @@ font_intern_prop (const char *str, ptrdiff_t len, int force_symbol) if (len == 1 && *str == '*') return Qnil; - if (!force_symbol && len >=1 && isdigit (*str)) + if (!force_symbol && 0 < len && '0' <= *str && *str <= '9') { for (i = 1; i < len; i++) - if (! isdigit (str[i])) + if (! ('0' <= str[i] && str[i] <= '9')) break; if (i == len) { - Lisp_Object num = string_to_number (str, 10, 0); - if (! INTEGERP (num)) - xsignal1 (Qoverflow_error, num); - return num; + EMACS_INT n; + + i = 0; + for (n = 0; (n += str[i++] - '0') <= MOST_POSITIVE_FIXNUM; n *= 10) + { + if (i == len) + return make_number (n); + if (MOST_POSITIVE_FIXNUM / 10 < n) + break; + } + + xsignal1 (Qoverflow_error, make_string (str, len)); } }