Skip to content

Commit b418f35

Browse files
committed
Fix for infinite recursive loop problem in load_pnm() (#85),
Thanks to @Loginsoft-Research
1 parent 41f6be4 commit b418f35

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

src/frompnm.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,13 +36,15 @@ pnm_get_line(unsigned char *p, unsigned char *end, unsigned char *line)
3636
int n;
3737

3838
do {
39+
/* read the line */
3940
for (n = 0 ; p < end && *p >= ' '; p++) {
4041
if (n < 255) {
4142
line[n++] = *p;
4243
}
4344
}
4445

45-
if (p < end && *p == '\n') {
46+
/* skip invald characters */
47+
if (p < end && *p < ' ') {
4648
p++;
4749
}
4850

0 commit comments

Comments
 (0)