kwo pushed a commit to branch master. http://git.enlightenment.org/legacy/imlib2.git/commit/?id=04b8c35e175c09d705725385beecbff125aeb496
commit 04b8c35e175c09d705725385beecbff125aeb496 Author: Kim Woelders <[email protected]> Date: Fri Jan 7 10:33:07 2022 +0100 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. --- src/modules/loaders/loader_xbm.c | 10 +++++++--- 1 file 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) --
