summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKim Woelders <kim@woelders.dk>2022-01-07 10:33:07 +0100
committerKim Woelders <kim@woelders.dk>2022-01-07 21:17:50 +0100
commit04b8c35e175c09d705725385beecbff125aeb496 (patch)
treed1d242d1f960e4fa57833ff06e1f55ead926c5f5
parentb123cb76745068ba0c882468b34c4dbae8c359b8 (diff)
downloadimlib2-04b8c35e175c09d705725385beecbff125aeb496.tar.gz
XBM loader: Correct load2() result when no header is found
Also require that the header is found within the first 30 lines in the file. Otherwise we may waste some time parsing large C files.
-rw-r--r--src/modules/loaders/loader_xbm.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/src/modules/loaders/loader_xbm.c b/src/modules/loaders/loader_xbm.c
index b240f11..74d0a68 100644
--- a/src/modules/loaders/loader_xbm.c
+++ b/src/modules/loaders/loader_xbm.c
@@ -87,7 +87,7 @@ load2(ImlibImage * im, int load_data)
void *fdata;
char buf[4096], tok1[1024], tok2[1024];
DATA32 *ptr, pixel;
- int i, x, y, bit;
+ int i, x, y, bit, nl;
const char *s;
int header, val, nlen;
@@ -113,7 +113,7 @@ load2(ImlibImage * im, int load_data)
x = y = 0;
header = 1;
- for (;;)
+ for (nl = 0;; nl++)
{
s = mm_gets(buf, sizeof(buf));
if (!s)
@@ -165,6 +165,9 @@ load2(ImlibImage * im, int load_data)
}
else
{
+ /* Quit if we don't have the header in N lines */
+ if (nl >= 30)
+ break;
continue;
}
}
@@ -205,7 +208,8 @@ load2(ImlibImage * im, int load_data)
}
done:
- rc = LOAD_SUCCESS;
+ if (!header)
+ rc = LOAD_SUCCESS;
quit:
if (rc <= 0)