Commit Graph

413 Commits

Author SHA1 Message Date
Kim Woelders eebe5a2747 Refactor imlib_create_scaled_image_from_drawable()
The X11 stuff should be in x11_grab.c, like the
imlib_create_image_from_drawable() implementation.
2021-11-23 20:33:25 +01:00
Kim Woelders 892af451f2 Trivial changes in __imlib_Grab...() function prototypes 2021-11-23 20:33:25 +01:00
Kim Woelders 63a0279785 Move pixmap stuff to x11_pixmap.c/h 2021-11-23 20:33:25 +01:00
Kim Woelders 21a4172e81 Move ImlibImagePixmap population to __imlib_AddImagePixmapToCache()
For similarity with __imlib_FindCachedImagePixmap().
2021-11-23 20:07:56 +01:00
Kim Woelders 59d6b148f5 Rename X11 related files for clarity
And only build them when BUILD_X11.
2021-11-23 20:07:56 +01:00
Kim Woelders 601cdb4d0d Remove some unneeded headers 2021-11-23 20:07:56 +01:00
Kim Woelders 688ab0edba Drop unnecessary free() NULL argument checks 2021-11-20 17:02:23 +01:00
Kim Woelders d9e2854f23 Loader loading: Don't bother looking up load() if we have load2() 2021-11-05 17:22:01 +01:00
Kim Woelders ac1f75daf0 Loader loading: Avoid always loading all loaders
Introduce "known loaders" list associating the known loader modules
with the usual file name extensions they handle.
If file name extensions match known ones we will only load the required
loader.
2021-11-05 17:22:01 +01:00
Kim Woelders 1cf913701c Loader loading: Minor loader lookup refactoring
Split off __imlib_LookupLoadedLoader() which just does lookup in loaded
loader list.
2021-11-05 17:22:01 +01:00
Kim Woelders a0b32e292b Loader loading: Move __imlib_GetLoaderList()
Paving the way for other changes.
2021-11-05 17:22:01 +01:00
Kim Woelders b45ea50c4b Loader loading: Move to __imlib_FindBestLoaderForFormat() 2021-11-05 17:22:01 +01:00
Kim Woelders 3b2d26deac Loader loading: Tweaks 2021-11-05 17:22:01 +01:00
Kim Woelders 59561dcb1b Introduce ARRAY_SIZE() 2021-11-05 17:22:01 +01:00
Kim Woelders 5433232308 Introduce UPDATE_FLAG()
Somewhat simpler.
2021-11-05 17:22:01 +01:00
Kim Woelders ae01ddf0b2 Introduce im->fsize 2021-10-22 19:27:47 +02:00
Kim Woelders 9996028e7d debug: Add some debug related to file access and image loading 2021-10-22 19:26:58 +02:00
Kim Woelders e47e32a247 debug: Infrastructure
Add some debug infrastructure.
Disabled by default, enable with --enable-debug.
When enabled, the environment variable IMLIB2_DEBUG controls the amount
of debug output.
2021-10-22 19:24:15 +02:00
Kim Woelders 1f7ef0225e Imlib.h: Add version macros 2021-09-26 17:38:09 +02:00
Kim Woelders 5512f0a2e3 image.c: Use the LOAD_... macros to check loader return values 2021-09-16 10:54:09 +02:00
Kim Woelders adda6d7b9c GIF, TIFF, WEBP loaders: Fix loading if filename does not have usual suffix - take 2
Better solution from from Daniel Friesel <derf@finalrewind.org> / Lars
Stoltenow.
2021-09-15 19:43:48 +02:00
Kim Woelders 3c21caea23 Correct (disabled) debug printouts 2021-07-13 09:07:27 +02:00
Kim Woelders 49af0f9d59 Add feature to build with ASAN (--enable-gcc-asan) 2021-07-13 08:55:33 +02:00
Kim Woelders 651c56bb29 Drop unused Imlib_Object_List:last 2021-07-13 08:20:11 +02:00
Kim Woelders c31a5b98a2 Cleanups: while->for loops (pixmaps list) 2021-07-10 15:44:17 +02:00
Kim Woelders 6cfa4a4505 Cleanups: while->for loops (images list) 2021-07-10 15:44:17 +02:00
Kim Woelders 7a460e6a6e Cleanups: while->for loops (im->tags list) 2021-07-10 15:44:17 +02:00
Kim Woelders 4f3da0de03 Cleanups: while->for loops (context list) 2021-07-10 15:44:17 +02:00
Kim Woelders 3c645829b4 Cleanups: while->for loops (loaders list) 2021-07-10 15:44:17 +02:00
Kim Woelders 27ab891c56 Fix clang-analyzer warnings - lib (less trivial) 2021-04-16 17:15:06 +02:00
Kim Woelders e82a5997ec Fix clang-analyzer warnings - lib (mostly trivial) 2021-04-16 17:15:06 +02:00
Kim Woelders 90c5f5a26a context.c: Fix potential segv
Also call __imlib_FlushContexts() before adding new context, not after
- It's pointless to check the new context
- Avoids (bogus) clang-analyzer warning
2021-04-13 06:56:32 +02:00
Kim Woelders bdbea7b384 Remove unused Context functions 2021-04-13 06:56:32 +02:00
Kim Woelders 11cc9ffa51 Restore file:key functionality
Broken by 07e1601cd5 (in v1.7.0).
2021-04-12 20:39:36 +02:00
Kim Woelders 418d19e066 rend.c: Remove some pointless lines 2020-12-13 06:45:11 +01:00
Kim Woelders f4c04168b4 Remove some unnecessary X_DISPLAY_MISSING stuff 2020-12-13 06:45:11 +01:00
Kim Woelders e3be3eb0fc grab.c: Support 30bpp display in __imlib_GrabXImageToRGBA()
Patch by the_third.

https://phab.enlightenment.org/T8808
2020-12-06 14:16:45 +01:00
Kim Woelders 9219b2c6a3 rend.c: Fix __imlib_generic_render() when jump != 0
Patch by the_third.

https://phab.enlightenment.org/T8799
2020-12-06 14:14:09 +01:00
Kim Woelders 9e8978c6be Remove a couple of unused includes 2020-07-28 21:35:39 +02:00
Kim Woelders ea5da196cb Fix build without X11 2020-07-28 19:57:11 +02:00
Alexander Volkov 204d994d8c Don't rescan loaders
Summary:
Loaders from a newer version of imlib2 may be incompatible with an
older version of imlib2. Thus already running applications may
stop loading images after system upgrade, which can be extremely
unpleasant for the user.

Reviewers: kwo

Reviewed By: kwo

Differential Revision: https://phab.enlightenment.org/D11678
2020-04-14 17:34:41 +02:00
Alexander Volkov 5db012a35e Introduce imlib_load_image_from_fd()
Summary:
It can be used to load files in a process, which has no access to the file,
by passing the file descriptor to it. For example, in a sandboxed process.
Also anonymous files created with O_TMPFILE or by memfd_create() can be loaded.

Reviewers: kwo

Differential Revision: https://phab.enlightenment.org/D10262
2020-03-04 17:15:23 +01:00
Kim Woelders 07e1601cd5 Reduce number of stat() calls during load
Also skip empty files entirely.
2020-03-01 06:28:28 +01:00
Kim Woelders b9166551ac Add infrastructure for new loader entry - load2() 2020-02-29 18:04:34 +01:00
Kim Woelders c913f97285 __imlib_FileExtension: Use basename if there are no dots 2020-02-27 21:20:36 +01:00
Kim Woelders b059049034 Add a couple of consts 2020-02-23 13:26:00 +01:00
Kim Woelders 8d9f33d365 Fix enum conversion warnings (gcc10) 2020-02-01 19:30:03 +01:00
Kim Woelders 9eaed188d2 Make ImlibLoader struct opaque
Loaders should no longer directly access it.
2020-01-11 12:56:08 +01:00
Kim Woelders 875bc82b49 Introduce __imlib_LoaderSetFormats() 2020-01-11 12:55:08 +01:00
Kim Woelders c02dc3c975 Introduce __imlib_LoadEmbedded() 2020-01-11 12:55:08 +01:00
Kim Woelders 87c84278ec image.c: Add infrastructure to simplify progress handling 2020-01-04 15:30:20 +01:00
Kim Woelders 9f479126f9 image.c: Remove redundant pixmap unref
Already done in __imlib_ConsumeImage().
2020-01-04 15:30:20 +01:00
Kim Woelders 83e7e89348 image.c: Move data_memory_func assignment to better place 2019-12-28 12:06:22 +01:00
Kim Woelders 002df3c1fa image.c: Minor refactoring of pixmap cache cleaners 2019-12-28 12:06:22 +01:00
Kim Woelders a7be91805f image.c: Enable non-dirty pixmap cache cleaning
For whatever reason this does not seem to have ever been active.
Let's activate it now.
2019-12-28 12:06:22 +01:00
Kim Woelders 6acfd27058 image.c: Move loader functions to separate file 2019-12-28 12:06:22 +01:00
Kim Woelders 02e85ee069 image.c: Move image tag functions to separate file 2019-12-28 12:06:22 +01:00
Kim Woelders 0c7464f0db image.c/h: Cleanups
- Make a number of functions static
- Shuffle prototypes around for nicer grouping
- Remove unused __imlib_SetImageAlphaFlag()
- Remove __imlib_FlushCache() prototype (not implemented)
2019-12-28 12:06:22 +01:00
Kim Woelders bd3aa88242 Loader cleanups
- Do exit cleanups at exit.
- Merge data load conditions.
- Use LOAD_FAIL/SUCCESS/BREAK for load() exit code.
- Cosmetics.
2019-12-23 12:07:48 +01:00
Kim Woelders 540a98870b image.c: Use loader return value, not im->w to determine load success 2019-12-23 10:53:26 +01:00
Kim Woelders 670c8428a4 image.c: Introduce __imlib_ErrorFromErrno() 2019-12-23 10:53:26 +01:00
Kim Woelders c60ad00b1e image.c: Use real_file to get file time 2019-12-23 10:53:26 +01:00
Kim Woelders 0f4c0d9453 image.c: Don't strdup() real_name when not necessary in __imlib_LoadImage() 2019-12-23 10:53:26 +01:00
Kim Woelders 2c35a349ea image.c: Rework some obscure file name stuff in __imlib_SaveImage() 2019-12-23 10:53:26 +01:00
Kim Woelders c1b2686441 image.c: Remove some unnecessary clearing of calloc'ed structs 2019-12-23 10:53:26 +01:00
Kim Woelders 0c69bb64cc image.c: Add some space for readability 2019-12-23 10:53:26 +01:00
Kim Woelders cdf64148b0 Drop the __imlib_IsRealFile() file check in __imlib_File...() functions
There should be no reason to do this everywhere.
Only keep the one used when doing an image load.
2019-12-23 06:37:00 +01:00
Kim Woelders fa670dcbd7 Refactor many __imlib_File...() functions to use common __imlib_FileStat()
And drop unused __imlib_FilePermissions()
2019-12-23 06:37:00 +01:00
Kim Woelders 57b4b12c7e Simplify __imlib_FileExtension()
__imlib_FileExtension() has (presumably by mistake) never used the
"real" file name to determine the extension so let's just drop all the
strdup'ing and return a pointer into the file string.
2019-12-23 06:37:00 +01:00
Kim Woelders 3bd4e8032c Enable specifying loader/filter paths with environment variables
Useful for testing.
2019-12-03 17:26:24 +01:00
Kim Woelders 1a6a6b6433 Remove __imlib_AllocateData() w,h args
im->w and im->h must always be set before __imlib_AllocateData() is
called due to non-immediate loading (__imlib_AllocateData() only
comes in play when the pixel data must be loaded).
2019-11-16 21:18:12 +01:00
Kim Woelders 5d1e984e57 Simplify loader lookup functions 2019-11-10 15:11:56 +01:00
Kim Woelders 484bd5cc79 Eliminate READ_RGBA() 2019-11-09 12:07:15 +01:00
Kim Woelders 3e082b2310 Use macro for pixel color access in savers 2019-11-09 12:07:15 +01:00
Kim Woelders 755dc017f2 Use pixel instead of r,b,g,a in __imlib_render_str() 2019-11-09 12:07:04 +01:00
Kim Woelders e6269a9b9b Simplify pixel color handling in api.c 2019-11-09 11:32:17 +01:00
Kim Woelders 581e6baed8 Eliminate WRITE_RGBA()
Potentially causing way more memory access than needed.
2019-11-08 19:29:26 +01:00
Kim Woelders 2f228adbe1 Re-indent everything using indent-2.2.12 2019-11-08 18:57:36 +01:00
Kim Woelders 450463521f Rename/add byte swap macros 2019-10-11 15:28:53 +02:00
Kim Woelders 7f24775df1 Fix ABI break
And indent.
2019-10-10 17:16:29 +02:00
Alexander Volkov 03665627db Allow to use custom memory management functions for loaded images
Summary:
... and add imlib_create_image_using_data_and_memory_function().

For example, it allows to load an image in one process and then
pass it through shared memory to another process without extra
memory copy.

Reviewers: kwo

Differential Revision: https://phab.enlightenment.org/D10222
2019-09-30 19:11:32 +02:00
Kim Woelders ae9635b5d7 Fix memory leak in imlib_list_fonts()
Spotted by Sebastien Ballet.
2018-07-18 16:53:54 +02:00
Kim Woelders 89432fff5e Use common PIXEL_ARGB() macro to compose pixels 2018-07-17 19:31:04 +02:00
Kim Woelders 7206a84311 Move SWAP.. macro definitions to common.h 2018-07-17 19:31:04 +02:00
Kim Woelders b2e06bc6bd Remove obsolete dmalloc stuff
Also add some space in macros
2018-07-17 19:31:04 +02:00
Kim Woelders 8fcdc4965d Centralize handling of im->format
Instead of assigning it (in different ways) in each loader, do it
centrally in __imlib_LoadImageWrapper().

And a couple of cleanups in code related to im->format.
2018-07-17 19:31:04 +02:00
Kim Woelders 092c05acc3 Add __imlib_LoadImageWrapper() handling all load() calls
Loaders behave inconsistently on error so do cleanups in
__imlib_LoadImageWrapper()
2018-03-29 07:23:48 +02:00
Kim Woelders 4d6ff056ef grab.c: Fix gcc8 warning
grab.c: In function ‘__imlib_GrabDrawableToRGBA’:
grab.c:543:32: error: cast between incompatible function types from ‘void (*)(Display *, XErrorEvent *)’ {aka ‘void (*)(struct _XDisplay *, struct <anonymous> *)’} to ‘int (*)(Display *, XErrorEvent *)’ {aka ‘int (*)(struct _XDisplay *, struct <anonymous> *)’} [-Werror=cast-function-type]
    prev_erh = XSetErrorHandler((XErrorHandler) Tmp_HandleXError);
                                ^
2018-03-10 20:25:58 +01:00
Kim Woelders 1c55ef577d Add missing const to imlib_apply_filter() script argument 2018-03-10 20:25:58 +01:00
Kim Woelders a120e3152a Maximum image dimension should be 32767, not 32766
Presumably a glitch from when it last was lowered to "32767".
2018-03-10 20:19:55 +01:00
Kim Woelders 8038d9c618 Fix build without HAVE_X11_SHM_FD (T6752) 2018-03-07 19:44:05 +01:00
Kim Woelders 63103ae48c Expose XImage cache control functions 2018-02-17 13:23:13 +01:00
Kim Woelders 5cf3e34ff1 Add imlib_get_cache_used()
And some cosmetics.
2018-02-17 11:56:42 +01:00
Kim Woelders 327f8c0ce4 Refactor the XImage cache
Simpler, faster.
2018-02-10 10:53:42 +01:00
Kim Woelders 6a2e839313 Add IMLIB2_XIMAGE_CACHE_COUNT to enable testing the ximage cache 2018-02-10 10:30:16 +01:00
Kim Woelders 096316b476 Introduce IMLIB2_SHM_OPT to enable overriding/testing SHM modes 2018-02-10 10:30:16 +01:00
Kim Woelders c975dab9cd Fix potential OOB memory access if border sizes exceed image dimensions 2018-02-09 18:45:47 +01:00
Kim Woelders 96dde44a14 Fix potential OOB memory access if border elements are negative 2018-02-09 18:45:47 +01:00
Kim Woelders 65fb0c8249 Strip trailing whitespace, cosmetics 2018-02-09 18:45:32 +01:00
Kim Woelders 0f829f474b Indent 2018-02-08 15:37:56 +01:00
Alexander Volkov ca17031280 Add support for MIT-SHM FD-passing
Summary:
This is more secure way of using shared memory because
it's visible only to the X server and the application.

Reviewers: kwo

Reviewed By: kwo

Differential Revision: https://phab.enlightenment.org/D5788
2018-02-08 15:34:53 +01:00
Alexander Volkov 56ca24fc9f introduce __imlib_ShmDestroyXImage() instead of __imlib_ShmDetach()
Summary:
It enhances the code, because __imlib_ShmDestroyXImage() is symmetrical
to __imlib_ShmGetXImage(), while __imlib_ShmDetach() looks unrelated.

Reviewers: kwo

Reviewed By: kwo

Differential Revision: https://phab.enlightenment.org/D5787
2018-02-08 15:34:53 +01:00
Alexander Volkov 6f62c70bac put a check for shared memory inside __imlib_ShmGetXImage()
Summary:
This check actually refers to the internal implementation
and should not be done outside this function.

Reviewers: kwo

Reviewed By: kwo

Differential Revision: https://phab.enlightenment.org/D5783
2018-02-08 15:34:53 +01:00
Kim Woelders 8232c9213b imlib_create_scaled_image_from_drawable(): Drop shape handling if unshaped 2017-12-23 19:35:15 +01:00
Kim Woelders 257a72fabe imlib_create_scaled_image_from_drawable(): speed up 1:1 case 2017-12-23 19:32:52 +01:00
Kim Woelders 854fca3395 Remove redundant CAST_IMAGE() 2017-12-17 11:06:43 +01:00
Kim Woelders a3e8395435 Introduce __imlib_LoadImageData() 2017-12-17 11:06:38 +01:00
Kim Woelders 1c413c1f35 Make some more functions static. 2017-12-15 17:36:52 +01:00
Kim Woelders 1f96129e2c Fix missing break.
Found by gcc 7:

grab.c: In function ‘__imlib_GrabXImageToRGBA’:
grab.c:85:14: error: this statement may fall through [-Werror=implicit-fallthrough=]
              for (y = 0; y < h; y++)
              ^~~
grab.c:97:11: note: here
           case 24:
           ^~~~
2017-02-12 20:43:53 +01:00
Kim Woelders a0259d5181 Fix various potential OOM crashes.
There were several potential OOM crashes in __imlib_ListFilters(),
__imlib_ListLoaders() and __imlib_TrimLoaderList().

The fix of __imlib_TrimLoaderList() is from patch by
Yuriy M. Kaminskiy <yumkam@gmail.com>.
2016-04-16 17:35:08 +02:00
Kim Woelders 5b54980364 Move __imlib_ItemInList() to file.c.
It may not be the ideal location but it's better than image.c
2016-04-16 16:58:15 +02:00
Kim Woelders 31a261ac37 Trivial file function cleanups. 2016-04-15 22:05:22 +02:00
Kim Woelders b49e71ed77 Eliminate pImlibExternalFilter type. 2016-04-15 22:00:01 +02:00
Kim Woelders bdd7630a21 Make a number of functions static. 2016-04-15 21:59:52 +02:00
Yuriy M. Kaminskiy 633a8667b1 Harden API and internals against overly large images
Prevents potential integer overflow -> insufficient allocation -> heap overflow scenarios.
2016-04-13 22:21:58 +02:00
Alexander Smirnov 7836d83951 Fix cross-endianness for masks (1-bit depth images)
Summary:
Imlib generates masks on the client side with the bit order
of the client. Set this bit order for produced XImages.

Reviewers: kwo

Differential Revision: https://phab.enlightenment.org/D3891
2016-04-13 22:10:10 +02:00
Yuriy M. Kaminskiy 7eba2e4c8a Fix integer overflow resulting in insufficient heap allocation
IMAGE_DIMENSIONS_OK ensures that image width and height are less then
46340, so that maximum number of pixels is ~2**31.

Unfortunately, there are a lot of code that allocates image data with
something like

   malloc(w * h * sizeof(DATA32));

Obviously, on 32-bit machines this results in integer overflow,
insufficient heap allocation, with [massive] out-of-bounds heap
overwrite.
Either X_MAX should be reduced to 32767, or (w)*(h) should be checked to
not exceed ULONG_MAX/sizeof(DATA32).

Security implications:
*) for 32-bit machines: insufficient heap allocation and heap overwrite
in many image loaders, with escalation potential to remote code
execution;
*) for 64-bit machines: it seems, no impact.
2016-04-09 14:54:46 +02:00
Kim Woelders c94d83ccab Fix potential divide-by-zero in imlib_image_draw_ellipse().
Attempting to draw a 2x1 ellipse with e.g. imlib_image_draw_ellipse(x, y, 2, 1)
causes a divide-by-zero.
It seems happy enough to draw 1x1, 1x2 and 2x2, but not 2x1.

Patch by Simon Lees.

https://bugs.debian.org/639414
2016-04-07 20:24:32 +02:00
Kim Woelders ce94edca1c Fix off-by-one OOB read in __imlib_MergeUpdate().
Patch by Yuriy M. Kaminskiy.

https://bugs.debian.org/819818
2016-04-06 02:36:23 +02:00
Kim Woelders 94a357482b Fix "assuming signed overflow does not occur" warning. 2016-03-21 09:16:24 +01:00
Kim Woelders bc35a1f7aa Remove redundant config.h. 2015-11-01 15:17:34 +01:00
Chloe Kudryavtsev 521573be21 add time.h include to common.h for time_t 2015-11-01 15:04:53 +01:00
Kim Woelders ec1b4319b8 Indent the remaining unindented files. 2014-12-20 17:02:11 +01:00
Kim Woelders e20587d7a7 Enable visibility hiding by default. 2014-12-20 10:35:28 +01:00
Kim Woelders 98cec42013 Remove __hidden.
Going to to set -fvisibility=hidden (as default) shortly...
2014-12-20 10:35:28 +01:00
Kim Woelders cd902be360 Don't include Imlib2.h indirectly via image.h.
Also avoid using EAPI internally (requiring Imlib2.h).
2014-12-20 10:35:28 +01:00
Kim Woelders 54594ccd8d Change a number of internal function names.
Consistenly use the __-prefix on internal imlib_... functions.
2014-12-16 20:35:37 +01:00
Kim Woelders a4dd5bcdc2 Autofoo macro cleanups (ac_->ec_).
- Changes names AC_/ac_ to EC_/ec_ to stay out of autoconf namespace.
2014-12-16 20:30:48 +01:00
Kim Woelders 55ddd412c3 Revert "__imlib_LoadImage(): Additionally check loader_ret to detect loader failures"
This reverts commit a104e317ce.

Breaks image loading in certain situations.

It seems that some loaders may return 0 even when load() "succeeds".

This appears to happen with the jpeg loader when not loading data
immediately (but only reading the header).
In this case jpeg_finish_decompress() exits via _JPEGFatalErrorHandler()
-> longjmp() causing the return code to be 0.

The fix reverted here is probably basically correct, but it will have to
wait until the loaders are fixed to behave properly.
2014-12-14 20:27:39 +01:00
Fabian Keil 60779351df imlib_save_image_with_error_return(): Check loader return code to prevent use of unitialized memor 2014-12-06 13:57:14 +09:00
Fabian Keil edaf7b669c imlib_save_image(): Check loader return code for errors
Prevents tons of:
==10646== Conditional jump or move depends on uninitialised value(s)
==10646==    at 0x4F7D30C: png_write_find_filter (pngwutil.c:2578)
==10646==    by 0x4F7568F: png_write_row (pngwrite.c:827)
==10646==    by 0x4F751B0: png_write_rows (pngwrite.c:587)
==10646==    by 0x4D40C7D: save (loader_png.c:373)
==10646==    by 0x1297084: __imlib_SaveImage (image.c:1282)
==10646==    by 0x124252B: imlib_save_image (api.c:4615)
==10646==    by 0x401990: main (imlib2_conv.c:74)
when trying to convert id:000134,src:000105,op:havoc,rep:32.
2014-12-06 13:57:14 +09:00
Fabian Keil a104e317ce __imlib_LoadImage(): Additionally check loader_ret to detect loader failures
Fixes:

==14822== Conditional jump or move depends on uninitialised value(s)
==14822==    at 0x4E08376: load (loader_tiff.c:285)
==14822==    by 0x1F7D70F: __imlib_LoadImage (image.c:1041)
==14822==    by 0x1F090E4: imlib_load_image_with_error_return (api.c:1299)
==14822==    by 0x40F47B: feh_load_image (imlib.c:252)
==14822==    by 0x42CA0E: winwidget_loadimage (winwidget.c:753)
==14822==    by 0x42C918: winwidget_create_from_file (winwidget.c:126)
==14822==    by 0x421869: init_slideshow_mode (slideshow.c:62)
==14822==    by 0x418F13: main (main.c:78)
==14822==
==14822== Conditional jump or move depends on uninitialised value(s)
==14822==    at 0x4E083BC: load (loader_tiff.c:285)
==14822==    by 0x1F7D70F: __imlib_LoadImage (image.c:1041)
==14822==    by 0x1F090E4: imlib_load_image_with_error_return (api.c:1299)
==14822==    by 0x40F47B: feh_load_image (imlib.c:252)
==14822==    by 0x42CA0E: winwidget_loadimage (winwidget.c:753)
==14822==    by 0x42C918: winwidget_create_from_file (winwidget.c:126)
==14822==    by 0x421869: init_slideshow_mode (slideshow.c:62)
==14822==    by 0x418F13: main (main.c:78)
==14822==

when scaling id:000407,src:000226,op:havoc,rep:32 in feh.
2014-12-06 13:57:14 +09:00
Fabian Keil 143f2993d7 Make IMAGE_DIMENSIONS_OK() more restrictive
Prevents invalid reads and unreasonably large memory allocations
with input/queue/id:000210,src:000114,op:int32,pos:3,val:be:+32,+cov:

==20321== Invalid read of size 1
==20321==    at 0x1FCDB16: __imlib_ScaleAARGB (scale.c:1043)
==20321==    by 0x1F9BF81: __imlib_RenderImage (rend.c:409)
==20321==    by 0x1F0F82C: imlib_render_image_part_on_drawable_at_size (api.c:1886)
==20321==    by 0x40CD75: gib_imlib_render_image_part_on_drawable_at_size (gib_imlib.c:231)
==20321==    by 0x42C732: winwidget_render_image (winwidget.c:576)
==20321==    by 0x417ACA: feh_event_handle_keypress (keyevents.c:598)
==20321==    by 0x4190DE: feh_main_iteration (main.c:119)
==20321==    by 0x418F45: main (main.c:82)
==20321==  Address 0x3a12e034 is 12 bytes before a block of size 1,965,846,976 alloc'd
==20321==    at 0x103D293: malloc (in /usr/local/lib/valgrind/vgpreload_memcheck-amd64-freebsd.so)
==20321==    by 0x5B3D1F1: load (loader_pnm.c:149)
==20321==    by 0x1F7D70F: __imlib_LoadImage (image.c:1041)
==20321==    by 0x1F090E4: imlib_load_image_with_error_return (api.c:1299)
==20321==    by 0x40F47B: feh_load_image (imlib.c:252)
==20321==    by 0x42CA0E: winwidget_loadimage (winwidget.c:753)
==20321==    by 0x42C918: winwidget_create_from_file (winwidget.c:126)
==20321==    by 0x421869: init_slideshow_mode (slideshow.c:62)
==20321==    by 0x418F13: main (main.c:78)
2014-12-06 13:57:14 +09:00
Mike Frysinger 4f36e69934 do not link with X libs when X is disabled
URL: https://bugs.gentoo.org/517670
2014-07-28 23:01:23 -04:00
Mike Frysinger cfa257c01f fix X_DISPLAY_MISSING redefined warnings when X is disabled
This is set up in config.h by configure, so avoid defining it again.
2014-07-28 22:59:35 -04:00
Kim Woelders 6b24728fb8 Header file cleanups. 2013-12-22 05:10:44 +01:00
Kim Woelders c10f5a4fa5 Remove empty format.c/h. 2013-12-22 05:10:44 +01:00
Kim Woelders 7e513f5b87 Remove OS/2 support.
Looks incomplete and unmaintained.
2013-12-22 05:10:44 +01:00
Kim Woelders fe82b9760c Autofoo updates.
- Eliminate deprecated AC_TRY_CPP.
- Use pkg-config in stead of freetype-config to get freetype info.
- Eliminate my_includes/my_libs.
- Clean up include paths.
2013-07-07 20:35:29 +02:00
Kim Woelders 842b550233 More warning fixes (64 bit). 2013-07-05 18:44:11 +02:00
Kim Woelders 0c647a7f24 Silence compiler warnings (lib). 2013-07-03 16:51:22 +02:00
Kim Woelders 6e41fe2e1a Set warning options when using gcc. 2013-07-03 15:07:51 +02:00
Kim Woelders 7514ec5276 Minor optimisation (avoid bogus valgrind complaint). 2013-07-02 09:00:37 +02:00
Kim Woelders ad756ccacf Cosmetics for readability. 2013-07-02 08:57:04 +02:00
Kim Woelders eee318461d Fix drawing of closed polygons in certain situations (ticket 2309).
Drawing of the closing line could be skipped depending on the specific
vertex coordinates (and order).

Can't say that I undestand the code completely but this change seems
to fix the problem, and I don't think it can cause trouble.
2013-03-24 20:28:31 +01:00
Kim Woelders d943d1ebea Change INCLUDES to AM_CPPFLAGS.
INCLUDES is deprecated.
2013-03-24 20:28:31 +01:00
Kim Woelders 41c3a967d0 Indent (most) .c files.
SVN revision: 58518
2011-04-09 09:24:44 +00:00
Kim Woelders 4c55d2c3f6 Better image cache time stamp test.
SVN revision: 57918
2011-03-20 17:19:02 +00:00
Lucas De Marchi 24909ec041 Fix typos
"he->the" where appropriate



SVN revision: 52493
2010-09-20 17:09:13 +00:00
Lucas De Marchi 2ef97d2252 Fix common misspellings
Following misspellings were fixed:

adn->and
alwasy->always
arbitary->arbitrary
cant->can't
commerical->commercial
comprimise->compromise
consistant->consistent
dependant->dependent
didnt->didn't
doesnt->doesn't
enviroments->environments
foudn->found
fucntion->function
isnt->isn't
iwth->with
mroe->more
neccesary->necessary
onyl->only
paranthesis->parenthesis
parralel->parallel
refernces->references
seperate->separate
shoudl->should
soem->some
wasnt->wasn't
wiht->with
wokr->work




SVN revision: 52023
2010-09-09 03:31:04 +00:00
Kim Woelders 9daceb518d Fix imlib_render_image_part_on_drawable_at_size() ...
... when using color modifier and not scaling (ticket 576).

SVN revision: 51846
2010-09-02 21:19:49 +00:00
Lucas De Marchi 43def7af7b Revert and re-apply badnull patch
Revert previous patch generated by badnull.cocci script, and apply the new one.
The main difference is that assert and assert-like functions are not touched
anymore.




SVN revision: 51650
2010-08-26 01:34:13 +00:00
Lucas De Marchi 35e8e96a61 Convert (hopefully) all comparisons to NULL
Apply badzero.cocci, badnull.coci and badnull2.cocci

This should convert all cases where there's a comparison to NULL to simpler
forms. This patch applies the following transformations:

code before patch               ||code after patch
===============================================================

return a == NULL;                 return !a;

return a != NULL;                 return !!a;

func(a == NULL);                  func(!a);

func(a != NULL);                  func(!!a);

b = a == NULL;                    b = !a;

b = a != NULL;                    b = !!a;

b = a == NULL ? c : d;            b = !a ? c : d;

b = a != NULL ? c : d;            b = a ? c : d;


other cases:

a == NULL                         !a
a != NULL                         a




SVN revision: 51487
2010-08-21 13:52:25 +00:00
Lucas De Marchi 5962d9d66c Apply memset-calloc.cocci
Change calls to malloc + memset to calloc whenever an automatic conversion can
be done.

Possible candidates are not treated here, only the ones we can be sure the
conversion is safe.



SVN revision: 51078
2010-08-13 12:53:08 +00:00
Lucas De Marchi 96d043addc FORMATTING
* Remove vim modelines:
 find . -name '*.[chx]' -exec sed -i '/\/\*$/ {N;N;/ \* vim:ts/d}' \{\} \;
 find . -name '*.[chx]' -exec sed -i '/\/[\*\/] *vim:/d' \{\} \;

* Remove leading blank lines:
 find . -name '*.[cxh]' -exec sed -i '/./,$!d'

If you use vim, use this in your .vimrc:
set ts=8 sw=3 sts=8 expandtab cino=>5n-3f0^-2{2(0W1st0



SVN revision: 50816
2010-08-04 16:57:32 +00:00
Lucas De Marchi b2a826a680 Remove unneeded code with notnull.cocci script
The notnull.cocci script from Coccinelle finds places where you check if a
variable is NULL, but it's known not to be NULL. The check can be safely
removed. For example, this code would be caught by notnull:

if (!var) return;
if (var && var->fld) { ... }

It's needless to check again if var is not NULL because if it's in fact NULL,
it would have returned on the previous "if". This commit removes all the
trivial places where this pattern happens. Another patch will be generated for
the more complex cases.


SVN revision: 50241
2010-07-14 02:05:47 +00:00
Carsten Haitzler e5a280efc1 minor buglet - w * w - duh!
SVN revision: 47825
2010-04-08 01:29:29 +00:00
Kim Woelders d3bdadd623 Remove unused __imlib_FileField functions.
SVN revision: 47773
2010-04-05 18:36:50 +00:00
Kim Woelders dcddb36686 Remove .cvsignores.
SVN revision: 47214
2010-03-14 15:25:09 +00:00
Kim Woelders f8d9efaec5 Oops - forgot extern.
SVN revision: 46591
2010-02-27 18:14:25 +00:00
Kim Woelders d67ea1d096 Avoid cast.
SVN revision: 46335
2010-02-20 11:51:07 +00:00
Kim Woelders 08183bec3f Only check XShmAttach once in __imlib_ShmGetXImage().
SVN revision: 46334
2010-02-20 11:51:04 +00:00
Kim Woelders 7bf03a945c Fix excessive checking for shm extension in __imlib_GrabDrawableToRGBA().
SVN revision: 46333
2010-02-20 11:51:02 +00:00
Kim Woelders d0d1a48672 Fix compiling .S files when using older automake (ticket 449).
SVN revision: 43354
2009-10-30 19:40:29 +00:00
Kim Woelders 9ca97f2001 Correct image dimension check (pixels are four bytes).
SVN revision: 43242
2009-10-24 06:29:21 +00:00
Carsten Haitzler 3bcb4f4746 handle modified dir date of 0
SVN revision: 42936
2009-10-07 12:07:53 +00:00
Kim Woelders dd93bae938 Fix build for x86 on x86_64.
As far as I can tell this fixes building on x86_64 with e.g.
'./configure --enable-mmx CFLAGS=-m32" or "rpmbuild --target i386 ..."
without breaking anything.


SVN revision: 41667
2009-08-10 16:26:20 +00:00
Kim Woelders 661a78dc57 Remove unimplemented imlib_clip_line prototype and documentation (ticket 379).
SVN revision: 41517
2009-07-27 21:35:25 +00:00
Kim Woelders 5619f9e257 Relax 8192 pixel dimension limit (ticket 361).
This time hopefully without buffer overflow issues.



SVN revision: 41516
2009-07-27 21:05:12 +00:00
Kim Woelders dedebfcc1a Relax 8192 pixel dimension limit (ticket 361).
SVN revision: 41412
2009-07-18 09:58:43 +00:00
Kim Woelders 9686658a3c Fix imlib_font_query_size width calculation when there are undefined
codepoints (ticket 230).


SVN revision: 39306
2009-03-01 12:14:27 +00:00
Kim Woelders 6c5afe6fa1 Fix alignment error on amd64 (patch from Erik Boettcher).
SVN revision: 38402
2009-01-01 13:59:21 +00:00
Kim Woelders 06a53a073d Refactor shm stuff.
SVN revision: 37378
2008-11-01 18:11:10 +00:00
Kim Woelders 29442b80f5 Remove redundant BUILD_X11 tests, indent.
SVN revision: 37145
2008-10-26 13:59:07 +00:00
Kim Woelders cd929604a1 Introduce imlib_context_disconnect_display().
imlib_context_disconnect_display() should be called when a display
connection is closed but the application continues using imlib2 with a
different display connection.
This is required to avoid to attempt to free cached GCs (in
__imlib_RenderImage) after the associated display connection has been
closed.
It is not unlikely that similar cleanups should be performed elsewhere
in this situation, but the __imlib_RenderImage GCs is the only case I
have found to cause trouble so far.


SVN revision: 35463
2008-08-13 17:55:16 +00:00
Kim Woelders aa033943a6 Add support for TrueType Collections (suggested by Arne Goetje, bug 487).
The font specifier format is now "font_name[:faceidx]/size" where
faceidx is an optional face index.


SVN revision: 34721
2008-06-01 21:34:26 +00:00
Vincent Torri 7378e6d6a7 * improve autotools stuff
* move libtool versioning from src/bin/Makefile.am to configure.in
 * formatting


SVN revision: 34563
2008-05-14 05:36:23 +00:00
Kim Woelders 86ed6a65a3 Fix HSV color conversion so it matches the API documentation (Dariusz Knocinski).
SVN revision: 34525
2008-05-10 16:40:42 +00:00
Kim Woelders d1b62b240c Fix destination image loading in __imlib_BlendImageToImage() (Victor Paesa - bug 480).
SVN revision: 34515
2008-05-09 17:45:55 +00:00
Kim Woelders 1657ce6e1c Fix destination image loading in __imlib_BlendImageToImageSkewed() (Victor Paesa - bug 479).
SVN revision: 34514
2008-05-09 17:45:35 +00:00
Kim Woelders 3c8de2fbef Remove incorrect test in __imlib_copy_alpha_data() (Victor Paesa - bug 475).
SVN revision: 34504
2008-05-07 21:41:44 +00:00
Kim Woelders 8571e8798c Fix destination image loading in imlib_image_copy_alpha_to_image() (Victor Paesa - bug 474).
SVN revision: 34503
2008-05-07 21:38:39 +00:00
Kim Woelders b2837013af Oops - missed one (malloc check).
SVN revision: 33364
2008-01-06 15:07:47 +00:00
Kim Woelders 8be6d59395 Handle some out-of-memory situations without crashing.
SVN revision: 33358
2008-01-06 13:57:26 +00:00
Kim Woelders 1a2f46814c Push initial ctxt - continued, wasn't done everywhere.
SVN revision: 33357
2008-01-06 13:57:09 +00:00
Carsten Haitzler 911e8a2f5c push initial ctxt too
SVN revision: 32645
2007-11-13 03:47:22 +00:00
Sebastian Dransfeld a50ee1d8c4 Fix signed warning.
SVN revision: 32341
2007-11-04 09:47:53 +00:00
Carsten Haitzler a4addf17e8 round as a #define - and xpm loader has extra rgb.txt sourc
SVN revision: 31485
2007-08-25 02:07:08 +00:00
Kim Woelders 1d74ab1d33 Mark some (new) functions deprecated as they are likely to be removed (see bug 118).
Change some names to match coding style a bit more.


SVN revision: 31021
2007-07-27 18:46:11 +00:00
Kim Woelders 275d89b1d9 Indent, rewrap long comment lines.
SVN revision: 31018
2007-07-27 17:26:58 +00:00
Carsten Haitzler b9c591d390 font chaining patch
SVN revision: 30940
2007-07-23 14:27:44 +00:00
Kim Woelders 46caef98e5 Indent C files.
SVN revision: 30046
2007-05-20 13:26:25 +00:00
Kim Woelders 00767dd69e Make code indentable.
SVN revision: 30044
2007-05-20 12:49:43 +00:00
Kim Woelders 90b72d509a Back out fontset patch.
SVN revision: 30034
2007-05-19 18:32:34 +00:00
Carsten Haitzler 82e00e2412 fontset patch from winfred
SVN revision: 29880
2007-05-06 13:54:43 +00:00
Carsten Haitzler f30c5145f7 up to 1.4.0 ...
SVN revision: 29879
2007-05-06 13:44:57 +00:00
Kim Woelders 5d28b4ba22 Add option to build with visibility=hidden + associated fixups.
SVN revision: 29454
2007-04-09 12:55:29 +00:00
Nathan Ingersoll 69380b3217 Protect against segfaults if XImage allocation fails.
Return usable status to the API caller so it can handle the error condition.


SVN revision: 28368
2007-02-15 04:15:03 +00:00
Mike Frysinger c5cfb22b4a cleanup and simplify ... this should also fix the preprocessor paste error seen on x86
SVN revision: 27943
2007-01-13 05:39:06 +00:00
Carsten Haitzler f0e51f6488 line patch for imlib2 from john williams.
SVN revision: 27381
2006-12-08 12:56:44 +00:00