Mercurial > emacs
changeset 99904:ba4876d944bc
Fix bug #1362. * image.c (x_clear_image_1): Do not free background under HAVE_NS, it is not an indexed color. * nsterm.m (free_indexed_color): Add argument checking. * nsfns.m: Move config.h to before system includes (advised by Dan N.).
author | Adrian Robert <Adrian.B.Robert@gmail.com> |
---|---|
date | Tue, 25 Nov 2008 02:45:39 +0000 |
parents | 8fb8b5898508 |
children | 40ed8998219f |
files | src/image.c src/nsfns.m src/nsfont.m src/nsimage.m src/nsmenu.m src/nsselect.m src/nsterm.m |
diffstat | 7 files changed, 39 insertions(+), 10 deletions(-) [+] |
line wrap: on
line diff
--- a/src/image.c Tue Nov 25 02:12:27 2008 +0000 +++ b/src/image.c Tue Nov 25 02:45:39 2008 +0000 @@ -1622,10 +1622,7 @@ { Free_Pixmap (FRAME_X_DISPLAY (f), img->pixmap); img->pixmap = NO_PIXMAP; -#ifdef HAVE_NS - if (img->background_valid) - ns_free_indexed_color(img->background, f); -#endif + /* NOTE (HAVE_NS): background color is NOT an indexed color! */ img->background_valid = 0; }
--- a/src/nsfns.m Tue Nov 25 02:12:27 2008 +0000 +++ b/src/nsfns.m Tue Nov 25 02:45:39 2008 +0000 @@ -25,9 +25,13 @@ GNUstep port and post-20 update by Adrian Robert (arobert@cogsci.ucsd.edu) */ +/* This should be the first include, as it may set up #defines affecting + interpretation of even the system includes. */ +#include "config.h" + #include <signal.h> #include <math.h> -#include "config.h" + #include "lisp.h" #include "blockinput.h" #include "nsterm.h" @@ -36,7 +40,6 @@ #include "keyboard.h" #include "termhooks.h" #include "fontset.h" - #include "character.h" #include "font.h"
--- a/src/nsfont.m Tue Nov 25 02:12:27 2008 +0000 +++ b/src/nsfont.m Tue Nov 25 02:45:39 2008 +0000 @@ -20,6 +20,8 @@ Author: Adrian Robert (arobert@cogsci.ucsd.edu) */ +/* This should be the first include, as it may set up #defines affecting + interpretation of even the system includes. */ #include "config.h" #include "lisp.h"
--- a/src/nsimage.m Tue Nov 25 02:12:27 2008 +0000 +++ b/src/nsimage.m Tue Nov 25 02:45:39 2008 +0000 @@ -25,7 +25,10 @@ GNUstep port and post-20 update by Adrian Robert (arobert@cogsci.ucsd.edu) */ +/* This should be the first include, as it may set up #defines affecting + interpretation of even the system includes. */ #include "config.h" + #include "lisp.h" #include "dispextern.h" #include "nsterm.h"
--- a/src/nsmenu.m Tue Nov 25 02:12:27 2008 +0000 +++ b/src/nsmenu.m Tue Nov 25 02:45:39 2008 +0000 @@ -21,7 +21,10 @@ Christian Limpach, Scott Bender, Christophe de Dinechin) and code in the Carbon version by Yamamoto Mitsuharu. */ +/* This should be the first include, as it may set up #defines affecting + interpretation of even the system includes. */ #include "config.h" + #include "lisp.h" #include "window.h" #include "buffer.h"
--- a/src/nsselect.m Tue Nov 25 02:12:27 2008 +0000 +++ b/src/nsselect.m Tue Nov 25 02:45:39 2008 +0000 @@ -25,7 +25,10 @@ GNUstep port and post-20 update by Adrian Robert (arobert@cogsci.ucsd.edu) */ +/* This should be the first include, as it may set up #defines affecting + interpretation of even the system includes. */ #include "config.h" + #include "lisp.h" #include "nsterm.h" #include "termhooks.h"
--- a/src/nsterm.m Tue Nov 25 02:12:27 2008 +0000 +++ b/src/nsterm.m Tue Nov 25 02:45:39 2008 +0000 @@ -25,12 +25,15 @@ GNUstep port and post-20 update by Adrian Robert (arobert@cogsci.ucsd.edu) */ +/* This should be the first include, as it may set up #defines affecting + interpretation of even the system includes. */ +#include "config.h" + #include <math.h> #include <sys/types.h> #include <time.h> #include <unistd.h> -#include "config.h" #include "lisp.h" #include "blockinput.h" #include "sysselect.h" @@ -1280,7 +1283,6 @@ color_table->size * sizeof (NSColor *)); } idx = color_table->avail++; - index = [NSNumber numberWithUnsignedInt: idx]; } color_table->colors[idx] = color; @@ -1293,10 +1295,26 @@ void ns_free_indexed_color (unsigned long idx, struct frame *f) { - struct ns_color_table *color_table = FRAME_NS_DISPLAY_INFO (f)->color_table; + struct ns_color_table *color_table; NSColor *color; - if (!idx) + NSNumber *index; + + if (!f) return; + + color_table = FRAME_NS_DISPLAY_INFO (f)->color_table; + + if (idx <= 0 || idx >= color_table->size) { + message1("ns_free_indexed_color: Color index out of range.\n"); + return; + } + + index = [NSNumber numberWithUnsignedInt: idx]; + if ([color_table->empty_indices containsObject: index]) { + message1("ns_free_indexed_color: attempt to free already freed color.\n"); + return; + } + color = color_table->colors[idx]; [color release]; color_table->colors[idx] = nil;