Subject: Re: bug#9990: valgrind warning in add_row_entry

From: Dan Nicolaescu <[email-masked]>
Date: Fri, 11 Nov 2011 15:20:19 -0500

Eli Zaretskii <[email-masked]> writes:

>> Date: Fri, 11 Nov 2011 17:30:58 +0200
>> From: Eli Zaretskii <[email-masked]>
>> Cc: [email-masked]
>> 
>> However, I spotted something strange related to the call to
>> row_equal_p, here:
>> 
>>   /* Skip over rows equal at the bottom.  */
>>   i = last_new;
>>   j = last_old;
>>   while (i - 1 > first_new
>>          && j - 1 > first_old
>>          && MATRIX_ROW (current_matrix, i - 1)->enabled_p
>> 	 && (MATRIX_ROW (current_matrix, i - 1)->y
>> 	     == MATRIX_ROW (desired_matrix, j - 1)->y)
>> 	 && !MATRIX_ROW (desired_matrix, j - 1)->redraw_fringe_bitmaps_p
>>          && row_equal_p (MATRIX_ROW (desired_matrix, i - 1),
>>                          MATRIX_ROW (current_matrix, j - 1), 1))
>>     --i, --j;
>> 
>> Some of these conditions use incorrect indices to access the glyph
>> matrices: `i' should be used for the current matrix and `j' for the
>> desired matrix.  Some of these conditions use `i' and `j' correctly,
>> some don't.
>
> Below is a patch I intend to install, if no one finds any thinko in
> it.  Dan, can you try this and see if it resolves the valgrind
> complaints (assuming you can reproduce them)?
>
> === modified file 'src/dispnew.c'
> --- src/dispnew.c	2011-10-08 10:58:50 +0000
> +++ src/dispnew.c	2011-11-11 15:53:27 +0000
> @@ -4334,10 +4334,10 @@ scrolling_window (struct window *w, int 
>    j = last_old;
>    while (i - 1 > first_new
>           && j - 1 > first_old
> -         && MATRIX_ROW (current_matrix, i - 1)->enabled_p
> -	 && (MATRIX_ROW (current_matrix, i - 1)->y
> -	     == MATRIX_ROW (desired_matrix, j - 1)->y)
> -	 && !MATRIX_ROW (desired_matrix, j - 1)->redraw_fringe_bitmaps_p
> +         && MATRIX_ROW (current_matrix, j - 1)->enabled_p
> +	 && (MATRIX_ROW (current_matrix, j - 1)->y
> +	     == MATRIX_ROW (desired_matrix, i - 1)->y)
> +	 && !MATRIX_ROW (desired_matrix, i - 1)->redraw_fringe_bitmaps_p
>           && row_equal_p (MATRIX_ROW (desired_matrix, i - 1),
>                           MATRIX_ROW (current_matrix, j - 1), 1))
>      --i, --j;

I haven't seen the one in row_equal_p anymore (but that one was not easy
to reproduce), the ones in update_window still show up.