Fix crash in lookup_image on termcap frames.
authorKaroly Lorentey <lorentey@elte.hu>
Fri, 30 Dec 2005 05:29:31 +0000 (05:29 +0000)
committerKaroly Lorentey <lorentey@elte.hu>
Fri, 30 Dec 2005 05:29:31 +0000 (05:29 +0000)
* src/xdisp.c (get_glyph_string_clip_rects): Add extra parentheses and
  braces to prevent compiler warnings.
  (calc_pixel_width_or_height): Add xassert to check that the
  frame is alive.  Don't call `lookup_image' on a termcap frame.

* image.c (lookup_image): Don't initialize `c' until the xasserts have
  been run.

git-archimport-id: lorentey@elte.hu--2004/emacs--multi-tty--0--patch-476

src/image.c
src/xdisp.c

index 579c04e..0ed50ac 100644 (file)
@@ -1722,7 +1722,7 @@ lookup_image (f, spec)
      struct frame *f;
      Lisp_Object spec;
 {
-  struct image_cache *c = FRAME_X_IMAGE_CACHE (f);
+  struct image_cache *c;
   struct image *img;
   int i;
   unsigned hash;
@@ -1734,6 +1734,8 @@ lookup_image (f, spec)
   xassert (FRAME_WINDOW_P (f));
   xassert (valid_image_p (spec));
 
+  c = FRAME_X_IMAGE_CACHE (f);
+
   GCPRO1 (spec);
 
   /* Look up SPEC in the hash table of the image cache.  */
index df6bba2..6dd0a1f 100644 (file)
@@ -1891,7 +1891,7 @@ get_glyph_string_clip_rects (s, rects, n)
     }
 
   if ((s->for_overlaps & OVERLAPS_BOTH) == 0
-      || (s->for_overlaps & OVERLAPS_BOTH) == OVERLAPS_BOTH && n == 1)
+      || ((s->for_overlaps & OVERLAPS_BOTH) == OVERLAPS_BOTH && n == 1))
     {
 #ifdef CONVERT_FROM_XRECT
       CONVERT_FROM_XRECT (r, *rects);
@@ -1917,23 +1917,27 @@ get_glyph_string_clip_rects (s, rects, n)
        {
          rs[i] = r;
          if (r.y + r.height > row_y)
-           if (r.y < row_y)
-             rs[i].height = row_y - r.y;
-           else
-             rs[i].height = 0;
+           {
+             if (r.y < row_y)
+               rs[i].height = row_y - r.y;
+             else
+               rs[i].height = 0;
+           }
          i++;
        }
       if (s->for_overlaps & OVERLAPS_SUCC)
        {
          rs[i] = r;
          if (r.y < row_y + s->row->visible_height)
-           if (r.y + r.height > row_y + s->row->visible_height)
-             {
-               rs[i].y = row_y + s->row->visible_height;
-               rs[i].height = r.y + r.height - rs[i].y;
-             }
-           else
-             rs[i].height = 0;
+           {
+             if (r.y + r.height > row_y + s->row->visible_height)
+               {
+                 rs[i].y = row_y + s->row->visible_height;
+                 rs[i].height = r.y + r.height - rs[i].y;
+               }
+             else
+               rs[i].height = 0;
+           }
          i++;
        }
 
@@ -18010,6 +18014,8 @@ calc_pixel_width_or_height (res, it, prop, font, width_p, align_to)
   if (NILP (prop))
     return OK_PIXELS (0);
 
+  xassert (FRAME_LIVE_P (it->f));
+
   if (SYMBOLP (prop))
     {
       if (SCHARS (SYMBOL_NAME (prop)) == 2)
@@ -18126,7 +18132,8 @@ calc_pixel_width_or_height (res, it, prop, font, width_p, align_to)
       if (SYMBOLP (car))
        {
 #ifdef HAVE_WINDOW_SYSTEM
-         if (valid_image_p (prop))
+         if (FRAME_WINDOW_P (it->f)
+             && valid_image_p (prop))
            {
              int id = lookup_image (it->f, prop);
              struct image *img = IMAGE_FROM_ID (it->f, id);