1
0
mirror of https://github.com/rkd77/elinks.git synced 2024-06-20 00:15:31 +00:00

Fix a memory-corruption bug in the line justification algorithm.

This commit is contained in:
Andrzej Zaborowski 2005-10-24 00:30:36 +00:00 committed by Miciah Dashiel Butler Masters
parent 5ce3f23a2e
commit 4fe6e19dc6
2 changed files with 12 additions and 2 deletions

View File

@ -48,6 +48,9 @@ Andre Valente <a.valente@netcabo.pt>
Download completion notify
Portuguese and Brazilian-Portuguese translation updates
Andrzej Zaborowski <balrog@zabor.org>
Fix for a memory-corruption bug in the line justification algorithm.
Anton Voloshin <vav@isv.ru>
Proper encoding of form entries

View File

@ -790,6 +790,7 @@ justify_line(struct html_context *html_context, int y)
int pos;
int *space_list;
int spaces;
int diff;
assert(html_context);
if_assert_failed return;
@ -839,8 +840,14 @@ justify_line(struct html_context *html_context, int y)
/* Realign line */
if (spaces > 1) {
int diff = overlap(par_format) - len;
/* Diff is the difference between the width of the paragraph
* and the current length of the line. */
diff = overlap(par_format) - len;
/* We check diff > 0 because diff can be negative (i.e., we have
* an unbroken line of length > overlap(par_format))
* even when spaces > 1 if the line has only non-breaking spaces. */
if (spaces > 1 && diff > 0) {
int prev_end = 0;
int word;