summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdrian Robert <Adrian.B.Robert@gmail.com>2008-11-25 02:45:39 +0000
committerAdrian Robert <Adrian.B.Robert@gmail.com>2008-11-25 02:45:39 +0000
commit5a06864fb69973eb2be01e230a98d6c24ff2138c (patch)
tree4a9039884d5f65352c64a72970a8fdd198e3476f
parent3a37fceafaf3bf2697849012e20d265a228d431b (diff)
downloademacs-5a06864fb69973eb2be01e230a98d6c24ff2138c.tar.gz
emacs-5a06864fb69973eb2be01e230a98d6c24ff2138c.tar.bz2
emacs-5a06864fb69973eb2be01e230a98d6c24ff2138c.zip
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.).
-rw-r--r--src/image.c5
-rw-r--r--src/nsfns.m7
-rw-r--r--src/nsfont.m2
-rw-r--r--src/nsimage.m3
-rw-r--r--src/nsmenu.m3
-rw-r--r--src/nsselect.m3
-rw-r--r--src/nsterm.m26
7 files changed, 39 insertions, 10 deletions
diff --git a/src/image.c b/src/image.c
index b24feca3779..6701637f951 100644
--- a/src/image.c
+++ b/src/image.c
@@ -1622,10 +1622,7 @@ x_clear_image_1 (f, img, pixmap_p, mask_p, colors_p)
{
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;
}
diff --git a/src/nsfns.m b/src/nsfns.m
index 459c058f7ca..2e2d6a77b75 100644
--- a/src/nsfns.m
+++ b/src/nsfns.m
@@ -25,9 +25,13 @@ MacOSX/Aqua port by Christophe de Dinechin (descubes@earthlink.net)
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 @@ GNUstep port and post-20 update by Adrian Robert (arobert@cogsci.ucsd.edu)
#include "keyboard.h"
#include "termhooks.h"
#include "fontset.h"
-
#include "character.h"
#include "font.h"
diff --git a/src/nsfont.m b/src/nsfont.m
index 7adced73c12..fa5387aa0f0 100644
--- a/src/nsfont.m
+++ b/src/nsfont.m
@@ -20,6 +20,8 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
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"
diff --git a/src/nsimage.m b/src/nsimage.m
index cf974be6c43..0cbb4d0d116 100644
--- a/src/nsimage.m
+++ b/src/nsimage.m
@@ -25,7 +25,10 @@ MacOSX/Aqua port by Christophe de Dinechin (descubes@earthlink.net)
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"
diff --git a/src/nsmenu.m b/src/nsmenu.m
index 825568f6557..8b06bdaddf8 100644
--- a/src/nsmenu.m
+++ b/src/nsmenu.m
@@ -21,7 +21,10 @@ By Adrian Robert, based on code from original nsmenu.m (Carl Edman,
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"
diff --git a/src/nsselect.m b/src/nsselect.m
index 88f8b262507..fbbe86ecf51 100644
--- a/src/nsselect.m
+++ b/src/nsselect.m
@@ -25,7 +25,10 @@ MacOSX/Aqua port by Christophe de Dinechin (descubes@earthlink.net)
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"
diff --git a/src/nsterm.m b/src/nsterm.m
index ccfee9b57b0..d8b4f60aba7 100644
--- a/src/nsterm.m
+++ b/src/nsterm.m
@@ -25,12 +25,15 @@ MacOSX/Aqua port by Christophe de Dinechin (descubes@earthlink.net)
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 @@ ns_index_color (NSColor *color, struct frame *f)
color_table->size * sizeof (NSColor *));
}
idx = color_table->avail++;
- index = [NSNumber numberWithUnsignedInt: idx];
}
color_table->colors[idx] = color;
@@ -1293,10 +1295,26 @@ ns_index_color (NSColor *color, struct frame *f)
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;