aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorEli Zaretskii2013-10-10 22:26:13 +0300
committerEli Zaretskii2013-10-10 22:26:13 +0300
commit00036e1dd2f2194fbc7938076defbe2d7228c8a3 (patch)
tree1d85d9dcfcb15ebf87dc8a5958d7ca63e28b6669 /src
parent991496253a519d728a1041c157b37182a829d156 (diff)
downloademacs-00036e1dd2f2194fbc7938076defbe2d7228c8a3.tar.gz
emacs-00036e1dd2f2194fbc7938076defbe2d7228c8a3.zip
Attempt to fix crashes per bug #15575.
src/xdisp.c (deep_copy_glyph_row): Assert that the 'used' counts of FROM and TO are identical. Copy only the glyphs of TEXT_AREA. src/term.c (save_and_enable_current_matrix): Don't allocate and don't save margin areas. (restore_desired_matrix): Don't restore margin areas. (free_saved_screen): Don't free margin areas.
Diffstat (limited to 'src')
-rw-r--r--src/ChangeLog11
-rw-r--r--src/term.c40
-rw-r--r--src/xdisp.c22
3 files changed, 16 insertions, 57 deletions
diff --git a/src/ChangeLog b/src/ChangeLog
index e650c1e7d4d..4bd46642f43 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,14 @@
12013-10-10 Eli Zaretskii <eliz@gnu.org>
2
3 * xdisp.c (deep_copy_glyph_row): Assert that the 'used' counts of
4 FROM and TO are identical. Copy only the glyphs of TEXT_AREA.
5 (Bug#15575)
6
7 * term.c (save_and_enable_current_matrix): Don't allocate and
8 don't save margin areas.
9 (restore_desired_matrix): Don't restore margin areas.
10 (free_saved_screen): Don't free margin areas.
11
12013-10-10 Paul Eggert <eggert@cs.ucla.edu> 122013-10-10 Paul Eggert <eggert@cs.ucla.edu>
2 13
3 * image.c: Pacify --enable-gcc-warnings. 14 * image.c: Pacify --enable-gcc-warnings.
diff --git a/src/term.c b/src/term.c
index a8274b19d2a..a4f8f2ea17c 100644
--- a/src/term.c
+++ b/src/term.c
@@ -3066,22 +3066,6 @@ save_and_enable_current_matrix (struct frame *f)
3066 screen will not be redrawn anyway.) */ 3066 screen will not be redrawn anyway.) */
3067 to->enabled_p = 1; 3067 to->enabled_p = 1;
3068 to->hash = from->hash; 3068 to->hash = from->hash;
3069 if (from->used[LEFT_MARGIN_AREA])
3070 {
3071 nbytes = from->used[LEFT_MARGIN_AREA] * sizeof (struct glyph);
3072 to->glyphs[LEFT_MARGIN_AREA] = xmalloc (nbytes);
3073 memcpy (to->glyphs[LEFT_MARGIN_AREA],
3074 from->glyphs[LEFT_MARGIN_AREA], nbytes);
3075 to->used[LEFT_MARGIN_AREA] = from->used[LEFT_MARGIN_AREA];
3076 }
3077 if (from->used[RIGHT_MARGIN_AREA])
3078 {
3079 nbytes = from->used[RIGHT_MARGIN_AREA] * sizeof (struct glyph);
3080 to->glyphs[RIGHT_MARGIN_AREA] = xmalloc (nbytes);
3081 memcpy (to->glyphs[RIGHT_MARGIN_AREA],
3082 from->glyphs[RIGHT_MARGIN_AREA], nbytes);
3083 to->used[RIGHT_MARGIN_AREA] = from->used[RIGHT_MARGIN_AREA];
3084 }
3085 } 3069 }
3086 3070
3087 return saved; 3071 return saved;
@@ -3106,26 +3090,6 @@ restore_desired_matrix (struct frame *f, struct glyph_matrix *saved)
3106 to->used[TEXT_AREA] = from->used[TEXT_AREA]; 3090 to->used[TEXT_AREA] = from->used[TEXT_AREA];
3107 to->enabled_p = from->enabled_p; 3091 to->enabled_p = from->enabled_p;
3108 to->hash = from->hash; 3092 to->hash = from->hash;
3109 nbytes = from->used[LEFT_MARGIN_AREA] * sizeof (struct glyph);
3110 if (nbytes)
3111 {
3112 eassert (to->glyphs[LEFT_MARGIN_AREA] != from->glyphs[LEFT_MARGIN_AREA]);
3113 memcpy (to->glyphs[LEFT_MARGIN_AREA],
3114 from->glyphs[LEFT_MARGIN_AREA], nbytes);
3115 to->used[LEFT_MARGIN_AREA] = from->used[LEFT_MARGIN_AREA];
3116 }
3117 else
3118 to->used[LEFT_MARGIN_AREA] = 0;
3119 nbytes = from->used[RIGHT_MARGIN_AREA] * sizeof (struct glyph);
3120 if (nbytes)
3121 {
3122 eassert (to->glyphs[RIGHT_MARGIN_AREA] != from->glyphs[RIGHT_MARGIN_AREA]);
3123 memcpy (to->glyphs[RIGHT_MARGIN_AREA],
3124 from->glyphs[RIGHT_MARGIN_AREA], nbytes);
3125 to->used[RIGHT_MARGIN_AREA] = from->used[RIGHT_MARGIN_AREA];
3126 }
3127 else
3128 to->used[RIGHT_MARGIN_AREA] = 0;
3129 } 3093 }
3130} 3094}
3131 3095
@@ -3142,10 +3106,6 @@ free_saved_screen (struct glyph_matrix *saved)
3142 struct glyph_row *from = saved->rows + i; 3106 struct glyph_row *from = saved->rows + i;
3143 3107
3144 xfree (from->glyphs[TEXT_AREA]); 3108 xfree (from->glyphs[TEXT_AREA]);
3145 if (from->used[LEFT_MARGIN_AREA])
3146 xfree (from->glyphs[LEFT_MARGIN_AREA]);
3147 if (from->used[RIGHT_MARGIN_AREA])
3148 xfree (from->glyphs[RIGHT_MARGIN_AREA]);
3149 } 3109 }
3150 3110
3151 xfree (saved->rows); 3111 xfree (saved->rows);
diff --git a/src/xdisp.c b/src/xdisp.c
index 675ed638335..09b87e0ba0d 100644
--- a/src/xdisp.c
+++ b/src/xdisp.c
@@ -20589,34 +20589,22 @@ display_menu_bar (struct window *w)
20589static void 20589static void
20590deep_copy_glyph_row (struct glyph_row *to, struct glyph_row *from) 20590deep_copy_glyph_row (struct glyph_row *to, struct glyph_row *from)
20591{ 20591{
20592 int area, i, sum_used = 0; 20592 int area, i;
20593 struct glyph *pointers[1 + LAST_AREA]; 20593 struct glyph *pointers[1 + LAST_AREA];
20594 20594
20595 /* Save glyph pointers of TO. */ 20595 /* Save glyph pointers of TO. */
20596 memcpy (pointers, to->glyphs, sizeof to->glyphs); 20596 memcpy (pointers, to->glyphs, sizeof to->glyphs);
20597 eassert (to->used[TEXT_AREA] == from->used[TEXT_AREA]);
20597 20598
20598 /* Do a structure assignment. */ 20599 /* Do a structure assignment. */
20599 *to = *from; 20600 *to = *from;
20600 20601
20601 /* Restore original pointers of TO. */ 20602 /* Restore original glyph pointers of TO. */
20602 memcpy (to->glyphs, pointers, sizeof to->glyphs); 20603 memcpy (to->glyphs, pointers, sizeof to->glyphs);
20603 20604
20604 /* Count how many glyphs to copy and update glyph pointers. */
20605 for (area = LEFT_MARGIN_AREA; area < LAST_AREA; ++area)
20606 {
20607 if (area > LEFT_MARGIN_AREA)
20608 {
20609 eassert (from->glyphs[area] - from->glyphs[area - 1]
20610 == from->used[area - 1]);
20611 to->glyphs[area] = to->glyphs[area - 1] + to->used[area - 1];
20612 }
20613 sum_used += from->used[area];
20614 }
20615
20616 /* Copy the glyphs. */ 20605 /* Copy the glyphs. */
20617 eassert (sum_used <= to->glyphs[LAST_AREA] - to->glyphs[LEFT_MARGIN_AREA]); 20606 memcpy (to->glyphs[TEXT_AREA], from->glyphs[TEXT_AREA],
20618 for (i = 0; i < sum_used; i++) 20607 from->used[TEXT_AREA] * sizeof (struct glyph));
20619 to->glyphs[LEFT_MARGIN_AREA][i] = from->glyphs[LEFT_MARGIN_AREA][i];
20620} 20608}
20621 20609
20622/* Display one menu item on a TTY, by overwriting the glyphs in the 20610/* Display one menu item on a TTY, by overwriting the glyphs in the