src/sfnt/pngshim.c


Log

Author Commit Date CI Message
Werner Lemberg d399657f 2023-02-26T20:18:54 * src/*: Replace leading underscores with trailing ones in dummy variables. This is to avoid clang warnings.
Werner Lemberg ac5babe8 2023-02-08T19:36:10 Fix 'fall-through' warning messages. Modern compilers get more insistent on that... * include/freetype/internal/compiler-macros.h (FALL_THROUGH): Define. * src/*: Use it instead of `/* fall through */` comments.
Werner Lemberg da9eb9c7 2023-02-07T07:01:36 Fix minor clang and clang++ warnings.
Werner Lemberg 65f85237 2023-01-17T09:18:25 Update all copyright notices.
Werner Lemberg 695d606a 2022-04-01T08:50:33 Whitespace.
Werner Lemberg d0cfb4e1 2022-01-11T10:54:10 Update all copyright notices.
Alexei Podtelezhnikov 2583b608 2021-05-01T09:22:26 * src/sfnt/pngshim.c (Load_SBit_Png): Tweak allocaton macro.
Alexei Podtelezhnikov e9c50fa7 2021-03-16T22:12:41 * src/sfnt/pngshim.c (Load_SBit_Png): Free `rows` once later.
Ben Wagner b0729b8f 2021-03-15T14:32:24 [sfnt] Fix memory leak in png loading. Reported as https://bugs.chromium.org/p/chromium/issues/detail?id=1182552 Memory is allocated and the pointer assigned to `rows` inside a 'setjmp' scope. This memory must be freed outside the 'setjmp' scope after a 'longjmp'. Since `rows` is a local and modified inside the 'setjmp' scope it must be marked volatile or it will have an indeterminate value after the 'longjmp'. * src/sfnt/pngshim.c (Load_SBit_Png): Fix memory leak of `rows`.
Werner Lemberg 7227aabb 2021-03-04T06:41:30 Revert "[sfnt] Fix crash in `Load_SBit_Png` on Windows x64." This reverts commit dbf9142f7e0432c9ed618b3276e2b61fa39e7262, as discussed in #1037.
Jesse Towner dbf9142f 2021-02-25T15:07:25 [sfnt] Fix crash in `Load_SBit_Png` on Windows x64. This change fixes a crash that occurs in `Load_SBit_Png` when running on a 64-bit Windows OS. A memory access violation exception would be raised by `setjmp` if the `jmp_buf` is not aligned to a 16-byte memory boundary. This is due to setjmp executing `movdqa` instructions to store 128-bit XMM registers to memory, which require correct memory alignment. This problem occurs because `png_create_read_struct` uses `malloc` and `free` for memory management, which only guarantees 8-byte alignment on Windows. Instead, to fix the problem, `png_create_read_struct_2` is used on 64-bit Windows, which allows for user-defined memory allocation and deallocation callbacks to be specified. These callbacks forward the allocation and deallocation requests to `_aligned_alloc` and `_aligned_free`, ensuring that the allocated `png_struct` and internal `jmp_buf` have the requisite 16-byte alignment. * src/sfnt/pngshim.c <_WIN64>: Include `malloc.h`. (malloc_callback, free_callback) <_WIN64>: New functions. (Load_SBit_Png) <_WIN64>: Use `png_create_read_struct_2` instead of `png_create_read_struct`
Werner Lemberg b6e8a712 2021-01-17T07:18:48 Update all copyright notices.
Ben Wagner 007c109b 2020-10-23T08:29:14 * src/sfnt/pngshim.c (Load_SBit_Png): Fix memory leak (#59322). The issue is that `rows` is allocated but will not be freed in the event that the call to `png_read_image` fails and calls `longjmp`.
Werner Lemberg a3bab162 2020-10-19T23:45:28 [sfnt] Fix heap buffer overflow (#59308). This is CVE-2020-15999. * src/sfnt/pngshim.c (Load_SBit_Png): Test bitmap size earlier.
Stephen McDowell d924c5cf 2020-06-19T04:14:39 [sfnt] Support Intel compilers. * src/sfnt/pngshim.c (premultiply_data): Intel compilers do not currently support `__builtin_shuffle'.
Werner Lemberg 16586859 2020-06-13T21:15:45 Remove redundant inclusion of `ft2build.h'. * */*: Remove `#include <ft2build.h>' where possible. * include/freetype/freetype.h: Remove cpp error about missing inclusion of `ft2build.h'.
David Turner e1339133 2020-06-08T13:31:55 Make macros for header file names optional. We no longer have to take care of the 8.3 file name limit; this allows us (a) to introduce longer, meaningful file names, and (b) to avoid macro names in `#include' lines altogether since some compilers (most notably Visual C++) doesn't support this properly. */*: Replace #include FOO_H with #include <freetype/foo.h> or something similar. Also update the documentation.
Werner Lemberg e5038be7 2020-01-19T17:05:19 Update all copyright notices.
Alexei Podtelezhnikov 90a30f15 2019-10-10T22:04:50 * src/sfnt/pngshim.c (premultiply_data): Optimize for __SSE__ only.
Werner Lemberg 75859970 2019-02-23T10:07:09 Update all copyright notices.
Werner Lemberg f686ad46 2019-01-22T20:31:44 Update copyright years.
Werner Lemberg 9ac9060d 2018-06-03T09:01:17 [GSoC] src/*.*: Convert block comments to `light' style. This monster commit was created by applying Nikhil's scripts `docconverter.py' and `markify.py' to all C header and source files, followed up by minor manual clean-up. No change in functionality, of course. I used commit f7419907bc6044b9b7057f9789866426c804ba82 from https://github.com/nikramakrishnan/freetype-docs.git.
Werner Lemberg 0a0c2256 2018-01-02T09:33:57 Update copyright year.
Werner Lemberg 068a7a03 2017-12-18T20:34:05 * src/*/*: Only use `ft_' and `FT_' variants of stdc library stuff.
Jonathan Kew 0d1262a4 2017-09-24T17:36:47 [sfnt] Fix `premultiply_data' (#52092). * src/sfnt/pngshim.c (premultiply_data): Don't use vector extension if we have less than 16 bytes of data.
Werner Lemberg 39ce3ac4 2017-09-16T19:08:17 * Version 2.8.1 released. ========================= Tag sources with `VER-2-8-1'. * docs/VERSION.TXT: Add entry for version 2.8.1. * docs/CHANGES: Updated. * README, Jamfile (RefDoc), builds/windows/vc2005/freetype.vcproj, builds/windows/vc2005/index.html, builds/windows/vc2008/freetype.vcproj, builds/windows/vc2008/index.html, builds/windows/vc2010/freetype.vcxproj, builds/windows/vc2010/index.html, builds/windows/visualc/freetype.dsp, builds/windows/visualc/freetype.vcproj, builds/windows/visualc/index.html, builds/windows/visualce/freetype.dsp, builds/windows/visualce/freetype.vcproj, builds/windows/visualce/index.html, builds/wince/vc2005-ce/freetype.vcproj, builds/wince/vc2005-ce/index.html, builds/wince/vc2008-ce/freetype.vcproj, builds/wince/vc2008-ce/index.html: s/2.8/2.8.1/, s/28/281/. * include/freetype/freetype.h (FREETYPE_PATCH): Set to 1. * builds/unix/configure.raw (version_info): Set to 21:0:15. * CMakeLists.txt (VERSION_PATCH): Set to 1.
suzuki toshiya b757ddb1 2017-09-13T22:17:03 [sfnt] lowest gcc for vectors ( e1d0249e ) is changed to 4.7. __builtin_shuffle() was introduced in gcc-4.7. The lowest gcc to enable vector operation is delayed from 4.6 to 4.7. * src/sfnt/pngshim.c (premultiply_data): Fix cpp-macro to enable the vector operation, to change the lowest gcc version from 4.6 to 4.7.
Werner Lemberg e1d0249e 2017-08-23T08:18:22 [sfnt] Fix clang compilation (#51788). * src/sfnt/pngshim.c (premultiply_data): Use vectors instead of scalars. (vector_shuffle): New macro to take of a different built-in function name on clang.
Werner Lemberg cadd29de 2017-08-16T13:32:17 * src/sfnt/pngshim.c (premultiply_data): Fix compiler warnings.
Behdad Esfahbod c9d7c03f 2017-08-15T08:48:17 [sfnt] Speed up PNG image loading. This reduces the overhead of `premultiply_data' by 60%. * src/sfnt/pngshim.c (premultiply_data): Provide code which uses gcc's (and clang's) `vector_byte' attribute to process 4 pixels at a time.
Werner Lemberg 9931175d 2017-03-18T07:06:49 Improve `make multi'. * src/autofit/aflatin2.c: Guard file with FT_OPTION_AUTOFIT2. * src/base/ftmac.c: Guard more parts of the file with FT_MACINTOSH. * src/psaux/afmparse.c: Guard file with T1_CONFIG_OPTION_NO_AFM. * src/sfnt/pngshim.c: Guard file with TT_CONFIG_OPTION_EMBEDDED_BITMAPS also. * src/sfnt/ttbdf.c: Avoid empty source file. * src/sfnt/ttpost.c: Guard file with TT_CONFIG_OPTION_POSTSCRIPT_NAMES. * src/sfnt/ttsbit.c: Guard file with TT_CONFIG_OPTION_EMBEDDED_BITMAPS. * src/truetype/ttgxvar.c, src/truetype/ttinterp.c: Avoid empty source file. * src/truetype/ttsubpix.c: Guard file with TT_USE_BYTECODE_INTERPRETER also. * src/type1/t1afm.c: Guard file with T1_CONFIG_OPTION_NO_AFM. * src/autofit/autofit.c, src/base/ftbase.c, src/cache/ftcache.c, src/cff/cff.c, src/cid/type1cid.c, src/gxvalid/gxvalid.c, src/pcf/pcf.c, src/pfr/pfr.c, src/psaux/psaux.c, src/pshinter/pshinter.c, src/psnames/psnames.c, src/raster/raster.c, src/sfnt/sfnt.c, src/smooth/smooth.c, src/truetype/truetype.c, src/type1/type1.c, src/type42/type42.c: Remove conditionals; sort entries.
Alexei Podtelezhnikov a32270ae 2017-01-19T23:01:44 Typos.
Werner Lemberg 563ae780 2017-01-04T20:16:34 Update copyright year.
Werner Lemberg 1c6fd994 2016-11-06T12:37:55 [sfnt] Improve FT_LOAD_BITMAP_METRICS_ONLY for `sbix' format. It's unavoidable to call the PNG engine, but to get the metrics it is sufficient to read the PNG image's header only. * src/sfnt/pngshim.c (Load_SBit_Png): Add argument to control the allocation of the glyph slot. * src/sfnt/pngshim.h: Updated. * src/sfnt/ttsbit.c (tt_sbit_decoder_load_png, tt_face_load_sbix_image, tt_face_load_sbit_image): Updated.
Werner Lemberg 9adeab64 2016-01-13T11:54:10 Update copyright year.
Werner Lemberg 01f0842e 2015-02-22T12:03:28 [sfnt] Signedness fixes. * src/sfnt/pngshim.c, src/sfnt/sfobjs.c, src/sfnt/ttcmap.c, src/sfnt/ttkern.c, src/sfnt/ttload.c, src/sfnt/ttpost.c, src/sfnt/ttsbit.c: Apply. * src/sfnt/sfdriver.c: Apply. (sfnt_get_ps_name): Simplify.
Werner Lemberg f57fc59e 2015-01-17T20:41:43 Run `src/tools/update-copyright'.
Werner Lemberg f796cf6c 2015-01-17T20:11:10 Normalize copyright notice format.
Werner Lemberg 23c093fc 2014-11-21T08:41:39 Minor.
Werner Lemberg b3500af7 2014-11-19T21:28:21 Change some fields in `FT_Bitmap' to unsigned type. This doesn't break ABI. * include/ftimage.h (FT_Bitmap): Make `rows', `width', `num_grays', `pixel_mode', and `palette_mode' unsigned types. * src/base/ftbitmap.c: Updated. (FT_Bitmap_Copy): Fix casts. * src/cache/ftcsbits.c, src/raster/ftraster.c, src/sfnt/pngshim.c: Updated.
Werner Lemberg 54abd228 2014-11-15T09:05:22 [sfnt] Fix Savannah bug #43597. * src/sfnt/pngshim.c (Load_SBit_Png): Protect against too large bitmaps.
Werner Lemberg d9b4470e 2014-04-22T07:33:07 * src/sfnt/pngshim.c (error_callback): s/longjmp/ft_longjmp/.
Werner Lemberg 74a9b670 2013-08-02T14:53:32 [sfnt] Fix compilation with g++. * src/sfnt/pngshim.c (error_callback, read_data_from_FT_stream): Use cast. (Load_SBit_Png): Pacify compiler.
suzuki toshiya b4725cb7 2013-07-24T14:25:39 [sfnt] Fix for `make multi' target. * src/sfnt/pngshim.c (Load_SBit_Png): Use FT_LOCAL_DEF().
Werner Lemberg 01705395 2013-07-18T13:13:12 [sfnt] Add support for Apple's `sbix' color bitmap table. * include/freetype/internal/tttypes.h (TT_SBit_MetricsRec): Widen fields to FT_Short and FT_UShort, respectively. (TT_SBitTableType): New enumeration. (TT_FaceRec): Add `sbit_table_type' field. * include/freetype/tttags.h (TTAG_sbix): New macro. * src/sfnt/pngshim.c (Load_SBit_Png): Pass a more generic FT_GlyphSlot argument instead FT_Bitmap. Add flag to control map and metrics handling. Update all users. * src/sfnt/ttsbit.c: Include `ttmtx.h'. (tt_face_load_eblc): Renamed to... (tt_face_load_sbit): This. Handlic `sbix' bitmaps. (tt_face_free_eblc): Renamed to... (tt_face_load_sbit): This. Updated. (tt_face_load_strike_metrics): Handle `sbix' bitmaps. (tt_face_load_sbix_image): New function. (tt_sbit_decoder_alloc_bitmap, tt_sbit_decoder_load_image, tt_sbit_decoder_load_byte_aligned, tt_sbit_decoder_load_bit_aligned, tt_sbit_decoder_load_compound, tt_sbit_decoder_load_png, tt_sbit_decoder_load_image, tt_sbit_decoder_load_bitmap): Don't pass and handle load flags. (tt_sbit_decoder_load_bitmap) [!FT_CONFIG_OPTION_USE_PNG]: Better handle formats 17-19. Move color to grayscale conversion to... (tt_face_load_sbit_image): Here. Handle `sbix' bitmaps. * src/sfnt/pngshim.h: Updated. * src/sfnt/ttsbit.h: Updated. * src/sfnt/sfdriver.c: Updated.
Behdad Esfahbod 760d342d 2013-05-29T11:36:18 Add support for color embedded bitmaps (eg. color emoji). A new load flag, FT_LOAD_COLOR, makes FreeType load color embedded-bitmaps, following this draft specification https://color-emoji.googlecode.com/git/specification/v1.html which defines two new SFNT tables, `CBDT' and `CBLC' (named and modeled after `EBDT' and `EBLC', respectively). The color bitmaps are stored in the new FT_PIXEL_MODE_BGRA format to represent BGRA pre-multiplied sRGB images. If PNG support is available, PNG color images as defined in the same proposed specification are supported also. Note that color bitmaps are converted to grayscale if client didn't ask for color. * builds/unix/configure.raw: Search for libpng. Add `--without-png' option. * devel/ftoption.h, include/freetype/config/ftoption.h (FT_CONFIG_OPTION_USE_PNG): New macro. * include/freetype/freetype.h (FT_LOAD_COLOR): New load flag. * include/freetype/ftimage.h (FT_Pixel_Mode): Add `FT_PIXEL_MODE_BGRA'. * include/freetype/tttags.h (TTAG_CBDT, TTAG_CBLC): New tags. * src/base/ftbitmap.c (FT_Bitmap_Embolden): Updated. (ft_gray_for_premultiplied_srgb_bgra): New function. (FT_Bitmap_Convert): Handle FT_PIXEL_MODE_BGRA. * src/sfnt/pngshim.c, src/sfnt/pngshim.h: New files. * src/sfnt/sfnt.c: Include `pngshim.c'. * src/sfnt/ttsbit.c: Include FT_BITMAP_H and `pngshim.h' (tt_face_load_eblc): Load `CBLC'. (tt_sbit_decoder_init): Load `CBDT'. (tt_sbit_decoder_alloc_bitmap): Pass load flags to select between color and grayscale bitmaps. Set `num_grays'. This is used by `ftview' to choose the blending algorithm. (tt_sbit_decoder_load_byte_aligned, tt_sbit_decoder_load_bit_aligned, tt_sbit_decoder_load_compound, tt_sbit_decoder_load_image): Pass load flag. s/write/pwrite/. Don't call `tt_sbit_decoder_alloc_bitmap'. Updated. (tt_sbit_decoder_load_png) [FT_CONFIG_OPTION_USE_PNG]: New function. (tt_sbit_decoder_load_bitmap): Pass load flag. Handle new glyph formats 17, 18, and 19. Call `tt_sbit_decoder_alloc_bitmap'. Flatten color bitmaps if necessary. (tt_face_load_sbit_image): Updated. * src/sfnt/rules.mk (SFNT_DRV_SRC): Add `pngshim.c'. * docs/CHANGES: Updated.