Revision: 0a551d68cf07 Branch: default Author: John Boyer <john.boyer@xxxxxxxxxxxxxxxxx> Date: Tue Oct 1 18:19:30 2013 UTC Log: fixed the big bug in utd2brf.c http://code.google.com/p/liblouisutdml/source/detail?r=0a551d68cf07 Modified: /liblouisutdml/utd2brf.c ======================================= --- /liblouisutdml/utd2brf.c Mon Sep 30 00:05:42 2013 UTC +++ /liblouisutdml/utd2brf.c Tue Oct 1 18:19:30 2013 UTC @@ -114,7 +114,8 @@ brf_insertCharacters (const char *text, int length) { int k; - if ((ud->outbuf1_len_so_far + length) > ud->outbuf1_len) + if (length <= 0 || (ud->outbuf1_len_so_far + length) > + ud->outbuf1_len) return 0; for (k = 0; k < length; k++) ud->outbuf1[ud->outbuf1_len_so_far++] = text[k]; @@ -200,8 +201,8 @@ firstPage = 0; return 1; } - if (ud->outbuf1_len_so_far > 0) - for (; ud->outbuf1[ud->outbuf1_len_so_far - 1] <= ' '; + for (; ud->outbuf1_len_so_far > 0 + && ud->outbuf1[ud->outbuf1_len_so_far - 1] <= ' '; ud->outbuf1_len_so_far--); brf_insertCharacters (ud->lineEnd, strlen (ud->lineEnd)); brf_insertCharacters (ud->pageEnd, strlen (ud->pageEnd)); @@ -216,8 +217,8 @@ int k; int leadingBlanks; int linePos; - if (ud->outbuf1_len_so_far > 0) - for (; ud->outbuf1[ud->outbuf1_len_so_far - 1] <= ' '; + for (; ud->outbuf1_len_so_far > 0 + && ud->outbuf1[ud->outbuf1_len_so_far - 1] <= ' '; ud->outbuf1_len_so_far--); if (firstLineOnPage) { @@ -225,10 +226,11 @@ firstLineOnPage = 0; } xy = (char *) xmlGetProp (node, (xmlChar *) "xy"); - for (k = 0; xy[k] != ','; k++); - leadingBlanks = (atoi (xy) - ud->left_margin) / ud->cell_width; + k = atoi (xy); + leadingBlanks = (k - ud->left_margin) / ud->cell_width; if (leadingBlanks < 0 || leadingBlanks > ud->cells_per_line) leadingBlanks = 0; + for (k = 0; xy[k] != ','; k++); linePos = atoi (&xy[k + 1]); if (linePos < ud->page_top) linePos = ud->page_top; For a description of the software, to download it and links to project pages go to http://www.abilitiessoft.com