]> code.delx.au - gnu-emacs/commitdiff
x-load-color-file: avoid array bounds error
authorJim Meyering <jim@meyering.net>
Tue, 9 Jun 2009 05:57:35 +0000 (05:57 +0000)
committerJim Meyering <jim@meyering.net>
Tue, 9 Jun 2009 05:57:35 +0000 (05:57 +0000)
x-load-color-file expects each line of input to be of the form
"R G B name".  But if "name" is missing, it would read name[-1],
and if that value is '\n', zero it.
* xfaces.c (Fx_load_color_file): Handle missing color name.

src/ChangeLog
src/xfaces.c

index 399faf60b4721f687b8f73d024984564d04caea9..5287bf704c946424b27054c7e8348b075bd0b3b0 100644 (file)
@@ -1,3 +1,11 @@
+2009-06-09  Jim Meyering  <meyering@redhat.com>
+
+       x-load-color-file: avoid array bounds error
+       x-load-color-file expects each line of input to be of the form
+       "R G B name".  But if "name" is missing, it would read name[-1],
+       and if that value is '\n', zero it.
+       * xfaces.c (Fx_load_color_file): Handle missing color name.
+
 2009-06-09  Kenichi Handa  <handa@m17n.org>
 
        * charset.c (Fmap_charset_chars): In docstring, state clearly that
index 444376838b956de69511bfe40670ea7e3ea7cbaa..704d7a92049f108291cd27749e4cd418c6627024 100644 (file)
@@ -6630,7 +6630,7 @@ where R,G,B are numbers between 0 and 255 and name is an arbitrary string.  */)
          {
            char *name = buf + num;
            num = strlen (name) - 1;
-           if (name[num] == '\n')
+           if (num >= 0 && name[num] == '\n')
              name[num] = 0;
            cmap = Fcons (Fcons (build_string (name),
 #ifdef WINDOWSNT