summaryrefslogtreecommitdiff
path: root/apps/wps-display.c
diff options
context:
space:
mode:
Diffstat (limited to 'apps/wps-display.c')
-rw-r--r--apps/wps-display.c22
1 files changed, 14 insertions, 8 deletions
diff --git a/apps/wps-display.c b/apps/wps-display.c
index 563bb265be..846cea20d9 100644
--- a/apps/wps-display.c
+++ b/apps/wps-display.c
@@ -120,7 +120,7 @@ static void wps_format(char* fmt)
120 format_buffer[sizeof(format_buffer) - 1] = 0; 120 format_buffer[sizeof(format_buffer) - 1] = 0;
121 format_lines[line] = buf; 121 format_lines[line] = buf;
122 122
123 while (*buf) 123 while ((*buf) && (line < MAX_LINES))
124 { 124 {
125 switch (*buf) 125 switch (*buf)
126 { 126 {
@@ -134,7 +134,7 @@ static void wps_format(char* fmt)
134 if(*start_of_line != '#') /* A comment? */ 134 if(*start_of_line != '#') /* A comment? */
135 line++; 135 line++;
136 136
137 if (line <= MAX_LINES) 137 if (line < MAX_LINES)
138 { 138 {
139 /* the next line starts on the next byte */ 139 /* the next line starts on the next byte */
140 format_lines[line] = buf+1; 140 format_lines[line] = buf+1;
@@ -145,13 +145,19 @@ static void wps_format(char* fmt)
145 buf++; 145 buf++;
146 } 146 }
147 147
148 if(buf != format_lines[line]) 148 /* if supplied input didn't define a format line
149 /* the last line didn't terminate with a newline */ 149 for each line on the wps, set the rest to null */
150 line++; 150 if (line < MAX_LINES)
151
152 for (; line < MAX_LINES; line++)
153 { 151 {
154 format_lines[line] = NULL; 152 /* if the final line didn't terminate with a newline,
153 the line index wasn't incremented */
154 if (buf != format_lines[line])
155 line++;
156
157 for (; line < MAX_LINES; line++)
158 {
159 format_lines[line] = NULL;
160 }
155 } 161 }
156} 162}
157 163