texlive[46828] Build/source/libs: graphite2-1.3.11

commits+kakuto at tug.org commits+kakuto at tug.org
Mon Mar 5 10:10:55 CET 2018


Revision: 46828
          http://tug.org/svn/texlive?view=revision&revision=46828
Author:   kakuto
Date:     2018-03-05 10:10:55 +0100 (Mon, 05 Mar 2018)
Log Message:
-----------
graphite2-1.3.11

Modified Paths:
--------------
    trunk/Build/source/libs/README
    trunk/Build/source/libs/graphite2/ChangeLog
    trunk/Build/source/libs/graphite2/TLpatches/ChangeLog
    trunk/Build/source/libs/graphite2/TLpatches/TL-Changes
    trunk/Build/source/libs/graphite2/configure
    trunk/Build/source/libs/graphite2/graphite2-src/CMakeLists.txt
    trunk/Build/source/libs/graphite2/graphite2-src/ChangeLog
    trunk/Build/source/libs/graphite2/graphite2-src/README.md
    trunk/Build/source/libs/graphite2/graphite2-src/include/graphite2/Font.h
    trunk/Build/source/libs/graphite2/graphite2-src/src/CMakeLists.txt
    trunk/Build/source/libs/graphite2/graphite2-src/src/Code.cpp
    trunk/Build/source/libs/graphite2/graphite2-src/src/Collider.cpp
    trunk/Build/source/libs/graphite2/graphite2-src/src/Decompressor.cpp
    trunk/Build/source/libs/graphite2/graphite2-src/src/FeatureMap.cpp
    trunk/Build/source/libs/graphite2/graphite2-src/src/FileFace.cpp
    trunk/Build/source/libs/graphite2/graphite2-src/src/Pass.cpp
    trunk/Build/source/libs/graphite2/graphite2-src/src/SegCacheEntry.cpp
    trunk/Build/source/libs/graphite2/graphite2-src/src/Segment.cpp
    trunk/Build/source/libs/graphite2/graphite2-src/src/Silf.cpp
    trunk/Build/source/libs/graphite2/graphite2-src/src/TtfUtil.cpp
    trunk/Build/source/libs/graphite2/graphite2-src/src/gr_face.cpp
    trunk/Build/source/libs/graphite2/graphite2-src/src/gr_features.cpp
    trunk/Build/source/libs/graphite2/graphite2-src/src/gr_font.cpp
    trunk/Build/source/libs/graphite2/graphite2-src/src/gr_logging.cpp
    trunk/Build/source/libs/graphite2/graphite2-src/src/gr_segment.cpp
    trunk/Build/source/libs/graphite2/graphite2-src/src/inc/Code.h
    trunk/Build/source/libs/graphite2/graphite2-src/src/inc/Collider.h
    trunk/Build/source/libs/graphite2/graphite2-src/src/inc/Compression.h
    trunk/Build/source/libs/graphite2/graphite2-src/src/inc/FeatureMap.h
    trunk/Build/source/libs/graphite2/graphite2-src/src/inc/Font.h
    trunk/Build/source/libs/graphite2/graphite2-src/src/inc/List.h
    trunk/Build/source/libs/graphite2/graphite2-src/src/inc/Machine.h
    trunk/Build/source/libs/graphite2/graphite2-src/src/inc/Main.h
    trunk/Build/source/libs/graphite2/graphite2-src/src/inc/Segment.h
    trunk/Build/source/libs/graphite2/graphite2-src/src/inc/Sparse.h
    trunk/Build/source/libs/graphite2/graphite2-src/src/inc/opcode_table.h
    trunk/Build/source/libs/graphite2/graphite2-src/src/inc/opcodes.h
    trunk/Build/source/libs/graphite2/version.ac

Modified: trunk/Build/source/libs/README
===================================================================
--- trunk/Build/source/libs/README	2018-03-05 08:50:30 UTC (rev 46827)
+++ trunk/Build/source/libs/README	2018-03-05 09:10:55 UTC (rev 46828)
@@ -21,7 +21,7 @@
 gmp 6.1.2 - checked 16dec16
   http://ftp.gnu.org/gnu/gmp/
 
-graphite2 1.3.10 - checked 20jun17
+graphite2 1.3.11 - checked 05mar18
   http://sourceforge.net/projects/silgraphite/files/graphite2/
 
 harfbuzz 1.7.5 - checked 31jan18

Modified: trunk/Build/source/libs/graphite2/ChangeLog
===================================================================
--- trunk/Build/source/libs/graphite2/ChangeLog	2018-03-05 08:50:30 UTC (rev 46827)
+++ trunk/Build/source/libs/graphite2/ChangeLog	2018-03-05 09:10:55 UTC (rev 46828)
@@ -1,3 +1,8 @@
+2018-03-05  Akira Kakuto  <kakuto at fuk.kindai.ac.jp>
+
+	Import graphite2-1.3.11.
+	* version.ac: Adjusted.
+
 2017-06-20  Akira Kakuto  <kakuto at fuk.kindai.ac.jp>
 
 	Import graphite2-1.3.10.

Modified: trunk/Build/source/libs/graphite2/TLpatches/ChangeLog
===================================================================
--- trunk/Build/source/libs/graphite2/TLpatches/ChangeLog	2018-03-05 08:50:30 UTC (rev 46827)
+++ trunk/Build/source/libs/graphite2/TLpatches/ChangeLog	2018-03-05 09:10:55 UTC (rev 46828)
@@ -1,3 +1,8 @@
+2018-03-05  Akira Kakuto  <kakuto at fuk.kindai.ac.jp>
+
+	Imported graphite2-1.3.11 source tree from:
+	  http://sourceforge.net/projects/silgraphite/files/graphite2/
+
 2017-06-20  Akira Kakuto  <kakuto at fuk.kindai.ac.jp>
 
 	Imported graphite2-1.3.10 source tree from:

Modified: trunk/Build/source/libs/graphite2/TLpatches/TL-Changes
===================================================================
--- trunk/Build/source/libs/graphite2/TLpatches/TL-Changes	2018-03-05 08:50:30 UTC (rev 46827)
+++ trunk/Build/source/libs/graphite2/TLpatches/TL-Changes	2018-03-05 09:10:55 UTC (rev 46828)
@@ -1,4 +1,4 @@
-Changes applied to the graphite2-1.3.10/ tree as obtained from:
+Changes applied to the graphite2-1.3.11/ tree as obtained from:
 	http://sourceforge.net/projects/silgraphite/files/graphite2/
 
 Removed unused dirs:

Modified: trunk/Build/source/libs/graphite2/configure
===================================================================
--- trunk/Build/source/libs/graphite2/configure	2018-03-05 08:50:30 UTC (rev 46827)
+++ trunk/Build/source/libs/graphite2/configure	2018-03-05 09:10:55 UTC (rev 46828)
@@ -1,6 +1,6 @@
 #! /bin/sh
 # Guess values for system-dependent variables and create Makefiles.
-# Generated by GNU Autoconf 2.69 for graphite2 (TeX Live) 1.3.10.
+# Generated by GNU Autoconf 2.69 for graphite2 (TeX Live) 1.3.11.
 #
 # Report bugs to <tex-k at tug.org>.
 #
@@ -579,8 +579,8 @@
 # Identity of this package.
 PACKAGE_NAME='graphite2 (TeX Live)'
 PACKAGE_TARNAME='graphite2--tex-live-'
-PACKAGE_VERSION='1.3.10'
-PACKAGE_STRING='graphite2 (TeX Live) 1.3.10'
+PACKAGE_VERSION='1.3.11'
+PACKAGE_STRING='graphite2 (TeX Live) 1.3.11'
 PACKAGE_BUGREPORT='tex-k at tug.org'
 PACKAGE_URL=''
 
@@ -1254,7 +1254,7 @@
   # Omit some internal or obsolete options to make the list less imposing.
   # This message is too long to be a string in the A/UX 3.1 sh.
   cat <<_ACEOF
-\`configure' configures graphite2 (TeX Live) 1.3.10 to adapt to many kinds of systems.
+\`configure' configures graphite2 (TeX Live) 1.3.11 to adapt to many kinds of systems.
 
 Usage: $0 [OPTION]... [VAR=VALUE]...
 
@@ -1321,7 +1321,7 @@
 
 if test -n "$ac_init_help"; then
   case $ac_init_help in
-     short | recursive ) echo "Configuration of graphite2 (TeX Live) 1.3.10:";;
+     short | recursive ) echo "Configuration of graphite2 (TeX Live) 1.3.11:";;
    esac
   cat <<\_ACEOF
 
@@ -1419,7 +1419,7 @@
 test -n "$ac_init_help" && exit $ac_status
 if $ac_init_version; then
   cat <<\_ACEOF
-graphite2 (TeX Live) configure 1.3.10
+graphite2 (TeX Live) configure 1.3.11
 generated by GNU Autoconf 2.69
 
 Copyright (C) 2012 Free Software Foundation, Inc.
@@ -1558,7 +1558,7 @@
 This file contains any messages produced by compilers while
 running configure, to aid debugging if configure makes a mistake.
 
-It was created by graphite2 (TeX Live) $as_me 1.3.10, which was
+It was created by graphite2 (TeX Live) $as_me 1.3.11, which was
 generated by GNU Autoconf 2.69.  Invocation command line was
 
   $ $0 $@
@@ -3481,7 +3481,7 @@
 
 # Define the identity of the package.
  PACKAGE='graphite2--tex-live-'
- VERSION='1.3.10'
+ VERSION='1.3.11'
 
 
 cat >>confdefs.h <<_ACEOF
@@ -5577,7 +5577,7 @@
 # report actual input values of CONFIG_FILES etc. instead of their
 # values after options handling.
 ac_log="
-This file was extended by graphite2 (TeX Live) $as_me 1.3.10, which was
+This file was extended by graphite2 (TeX Live) $as_me 1.3.11, which was
 generated by GNU Autoconf 2.69.  Invocation command line was
 
   CONFIG_FILES    = $CONFIG_FILES
@@ -5643,7 +5643,7 @@
 cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
 ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`"
 ac_cs_version="\\
-graphite2 (TeX Live) config.status 1.3.10
+graphite2 (TeX Live) config.status 1.3.11
 configured by $0, generated by GNU Autoconf 2.69,
   with options \\"\$ac_cs_config\\"
 

Modified: trunk/Build/source/libs/graphite2/graphite2-src/CMakeLists.txt
===================================================================
--- trunk/Build/source/libs/graphite2/graphite2-src/CMakeLists.txt	2018-03-05 08:50:30 UTC (rev 46827)
+++ trunk/Build/source/libs/graphite2/graphite2-src/CMakeLists.txt	2018-03-05 09:10:55 UTC (rev 46828)
@@ -8,6 +8,8 @@
     set_property(CACHE CMAKE_BUILD_TYPE PROPERTY VALUE Release)
 endif (NOT CMAKE_BUILD_TYPE)
 
+option(BUILD_SHARED_LIBS "Make library a shared library instead of static" ON)
+
 enable_language(CXX C)
 
 include_directories(${PROJECT_SOURCE_DIR}/include)
@@ -23,6 +25,8 @@
 
 
 message(STATUS "Build: " ${CMAKE_BUILD_TYPE})
+string(REPLACE "ON"  "shared"  _LIB_OBJECT_TYPE ${BUILD_SHARED_LIBS})
+string(REPLACE "OFF" "static"  _LIB_OBJECT_TYPE ${_LIB_OBJECT_TYPE})
 string(REPLACE "ON" "disabled" _SEGCACHE_SUPPORT ${GRAPHITE2_NSEGCACHE})
 string(REPLACE "OFF" "enabled" _SEGCACHE_SUPPORT ${_SEGCACHE_SUPPORT})
 string(REPLACE "ON" "disabled" _FILEFACE_SUPPORT ${GRAPHITE2_NFILEFACE})
@@ -29,6 +33,7 @@
 string(REPLACE "OFF" "enabled" _FILEFACE_SUPPORT ${_FILEFACE_SUPPORT})
 string(REPLACE "ON" "disabled" _TRACING_SUPPORT ${GRAPHITE2_NTRACING})
 string(REPLACE "OFF" "enabled" _TRACING_SUPPORT ${_TRACING_SUPPORT})
+message(STATUS "Building library: " ${_LIB_OBJECT_TYPE})
 message(STATUS "Segment Cache support: " ${_SEGCACHE_SUPPORT})
 message(STATUS "File Face support: " ${_FILEFACE_SUPPORT})
 message(STATUS "Tracing support: " ${_TRACING_SUPPORT})

Modified: trunk/Build/source/libs/graphite2/graphite2-src/ChangeLog
===================================================================
--- trunk/Build/source/libs/graphite2/graphite2-src/ChangeLog	2018-03-05 08:50:30 UTC (rev 46827)
+++ trunk/Build/source/libs/graphite2/graphite2-src/ChangeLog	2018-03-05 09:10:55 UTC (rev 46828)
@@ -1,3 +1,8 @@
+1.3.11
+    . Fixes due to security review
+    . Minor collision avoidance fixes
+    . Fix LZ4 decompressor against high compression
+
 1.3.10
     . Address floating point build parameters to give consistent positioning results across platforms
     . Various bug fixes

Modified: trunk/Build/source/libs/graphite2/graphite2-src/README.md
===================================================================
--- trunk/Build/source/libs/graphite2/graphite2-src/README.md	2018-03-05 08:50:30 UTC (rev 46827)
+++ trunk/Build/source/libs/graphite2/graphite2-src/README.md	2018-03-05 09:10:55 UTC (rev 46828)
@@ -1,5 +1,12 @@
 # Graphite engine
 
+## Project CI status 
+Linux -- Intel 64bit:[![Build Status](http://build.palaso.org/app/rest/builds/buildType:bt124/statusIcon)](http://build.palaso.org/viewType.html?buildTypeId=bt124&guest=1)
+Intel 32bit:[![Build Status](http://build.palaso.org/app/rest/builds/buildType:bt123/statusIcon)](http://build.palaso.org/viewType.html?buildTypeId=bt123&guest=1)
+ARM 32bit:[![Build Status](http://build.palaso.org/app/rest/builds/buildType:Graphite_Linux32bitArm/statusIcon)](http://build.palaso.org/viewType.html?buildTypeId=Graphite_Linux32bitArm&guest=1)
+
+Windows -- Intel 64bit:[![Build Status](http://build.palaso.org/app/rest/builds/buildType:Graphite_Windows64bitProduction/statusIcon)](http://build.palaso.org/viewType.html?buildTypeId=Graphite_Windows64bitProduction&guest=1)
+
 ## What is Graphite?
 
 Graphite is a system that can be used to create “smart fonts” capable of displaying writing systems with various complex behaviors. A smart font contains not only letter shapes but also additional instructions indicating how to combine and position the letters in complex ways.

Modified: trunk/Build/source/libs/graphite2/graphite2-src/include/graphite2/Font.h
===================================================================
--- trunk/Build/source/libs/graphite2/graphite2-src/include/graphite2/Font.h	2018-03-05 08:50:30 UTC (rev 46827)
+++ trunk/Build/source/libs/graphite2/graphite2-src/include/graphite2/Font.h	2018-03-05 09:10:55 UTC (rev 46828)
@@ -30,7 +30,7 @@
 
 #define GR2_VERSION_MAJOR   1
 #define GR2_VERSION_MINOR   3
-#define GR2_VERSION_BUGFIX  10
+#define GR2_VERSION_BUGFIX  11
 
 #ifdef __cplusplus
 extern "C"

Modified: trunk/Build/source/libs/graphite2/graphite2-src/src/CMakeLists.txt
===================================================================
--- trunk/Build/source/libs/graphite2/graphite2-src/src/CMakeLists.txt	2018-03-05 08:50:30 UTC (rev 46827)
+++ trunk/Build/source/libs/graphite2/graphite2-src/src/CMakeLists.txt	2018-03-05 09:10:55 UTC (rev 46828)
@@ -56,6 +56,10 @@
     add_definitions(-DGRAPHITE2_TELEMETRY)
 endif (GRAPHITE2_TELEMETRY)
 
+if (NOT BUILD_SHARED_LIBS)
+    add_definitions(-DGRAPHITE2_STATIC)
+endif (NOT BUILD_SHARED_LIBS)
+
 set(GRAPHITE_HEADERS 
     ../include/graphite2/Font.h
     ../include/graphite2/Segment.h
@@ -65,7 +69,7 @@
 
 file(GLOB PRIVATE_HEADERS inc/*.h) 
 
-add_library(graphite2 SHARED
+add_library(graphite2
     ${GRAPHITE2_VM_TYPE}_machine.cpp
     gr_char_info.cpp
     gr_features.cpp
@@ -107,9 +111,9 @@
                                             LT_VERSION_AGE ${GRAPHITE_API_AGE})
 
 if  (${CMAKE_SYSTEM_NAME} STREQUAL "Linux")
-    set_target_properties(graphite2 PROPERTIES 
-        COMPILE_FLAGS   "-Wall -Wextra -Wno-unknown-pragmas -Wendif-labels -Wshadow -Wctor-dtor-privacy -Wnon-virtual-dtor -fno-rtti -fno-exceptions -fvisibility=hidden -fvisibility-inlines-hidden -fno-stack-protector"
-        LINK_FLAGS      "-nodefaultlibs ${GRAPHITE_LINK_FLAGS}" 
+    set_target_properties(graphite2 PROPERTIES
+        COMPILE_FLAGS   "-Wall -Wextra -Wno-unknown-pragmas -Wendif-labels -Wshadow -Wctor-dtor-privacy -Wnon-virtual-dtor -fno-rtti -fno-exceptions -fvisibility=hidden -fvisibility-inlines-hidden"
+        LINK_FLAGS      "-nodefaultlibs ${GRAPHITE_LINK_FLAGS}"
         LINKER_LANGUAGE C)
     if (${CMAKE_SYSTEM_PROCESSOR} MATCHES "x86|i.86")
         add_definitions(-mfpmath=sse -msse2)
@@ -130,7 +134,9 @@
             target_link_libraries(graphite2 c gcc)
         endif (GRAPHITE2_ASAN)
         include(Graphite)
-        nolib_test(stdc++ $<TARGET_SONAME_FILE:graphite2>)
+        if (BUILD_SHARED_LIBS)
+            nolib_test(stdc++ $<TARGET_SONAME_FILE:graphite2>)
+        endif (BUILD_SHARED_LIBS)
     endif (${CMAKE_CXX_COMPILER} MATCHES  ".*mingw.*")
     set(CMAKE_CXX_IMPLICIT_LINK_LIBRARIES "")
     CREATE_LIBTOOL_FILE(graphite2 "/lib${LIB_SUFFIX}")
@@ -137,9 +143,9 @@
 endif (${CMAKE_SYSTEM_NAME} STREQUAL "Linux")
 
 if  (${CMAKE_SYSTEM_NAME} STREQUAL "Darwin")
-    set_target_properties(graphite2 PROPERTIES 
-        COMPILE_FLAGS   "-Wall -Wextra -Wno-unknown-pragmas -Wimplicit-fallthrough -Wendif-labels -Wshadow -Wno-ctor-dtor-privacy -Wno-non-virtual-dtor -fno-rtti -fno-exceptions -fvisibility=hidden -fvisibility-inlines-hidden -fno-stack-protector -mfpmath=sse -msse2"
-        LINK_FLAGS      "-nodefaultlibs" 
+    set_target_properties(graphite2 PROPERTIES
+        COMPILE_FLAGS   "-Wall -Wextra -Wno-unknown-pragmas -Wimplicit-fallthrough -Wendif-labels -Wshadow -Wno-ctor-dtor-privacy -Wno-non-virtual-dtor -fno-rtti -fno-exceptions -fvisibility=hidden -fvisibility-inlines-hidden -mfpmath=sse -msse2"
+        LINK_FLAGS      "-nodefaultlibs"
         LINKER_LANGUAGE C)
     target_link_libraries(graphite2 c)
     include(Graphite)

Modified: trunk/Build/source/libs/graphite2/graphite2-src/src/Code.cpp
===================================================================
--- trunk/Build/source/libs/graphite2/graphite2-src/src/Code.cpp	2018-03-05 08:50:30 UTC (rev 46827)
+++ trunk/Build/source/libs/graphite2/graphite2-src/src/Code.cpp	2018-03-05 09:10:55 UTC (rev 46828)
@@ -219,7 +219,11 @@
     if (_out)
         *_out += total_sz;
     else
-        _code = static_cast<instr *>(realloc(_code, total_sz));
+    {
+      instr * const old_code = _code;
+      _code = static_cast<instr *>(realloc(_code, total_sz));
+      if (!_code) free(old_code);
+    }
    _data = reinterpret_cast<byte *>(_code + (_instr_count+1));
 
     if (!_code)
@@ -316,8 +320,9 @@
             if (_stack_depth <= 0)
                 failure(underfull_stack);
             break;
+        case NEXT_N :           // runtime checked
+            break;
         case NEXT :
-        case NEXT_N :           // runtime checked
         case COPY_NEXT :
             ++_out_index;
             if (_out_index < -1 || _out_index > _out_length || _slotref > _max.rule_length)

Modified: trunk/Build/source/libs/graphite2/graphite2-src/src/Collider.cpp
===================================================================
--- trunk/Build/source/libs/graphite2/graphite2-src/src/Collider.cpp	2018-03-05 08:50:30 UTC (rev 46827)
+++ trunk/Build/source/libs/graphite2/graphite2-src/src/Collider.cpp	2018-03-05 09:10:55 UTC (rev 46828)
@@ -306,7 +306,7 @@
         float seq_above_wt = cslot->seqAboveWt();
         float seq_below_wt = cslot->seqBelowWt();
         float seq_valign_wt = cslot->seqValignWt();
-        float lmargin = _margin;
+        float lmargin;
         // if isAfter, invert orderFlags for diagonal orders.
         if (isAfter)
         {
@@ -558,6 +558,8 @@
     {
         // Set up the bogus slot representing the exclusion glyph.
         Slot *exclSlot = seg->newSlot();
+        if (!exclSlot)
+            return res;
         exclSlot->setGlyph(seg, cslot->exclGlyph());
         Position exclOrigin(slot->origin() + cslot->exclOffset());
         exclSlot->origin(exclOrigin);
@@ -805,6 +807,8 @@
     {
         const BBox &bb = gc.getBoundingBBox(gid);
         const SlantBox &sb = gc.getBoundingSlantBox(gid);
+        if (sy + bb.yi - margin > y + width / 2 || sy + bb.ya + margin < y - width / 2)
+            return res;
         float td = sx - sy + y;
         float ts = sx + sy - y;
         if (isRight)
@@ -924,7 +928,7 @@
         }
     }
     done:
-    _mingap = (float)1e38;
+    _mingap = (float)1e37;      // less than 1e38 s.t. 1e38-_mingap is really big
     _target = aSlot;
     _margin = margin;
     _currShift = currShift;
@@ -945,7 +949,7 @@
     const float sx = slot->origin().x + currShift.x;
     float x = (sx + (rtl > 0 ? bb.tr.x : bb.bl.x)) * rtl;
     // this isn't going to reduce _mingap so skip
-    if (x < rtl * (_xbound - _mingap - currSpace))
+    if (_hit && x < rtl * (_xbound - _mingap - currSpace))
         return false;
 
     const float sy = slot->origin().y + currShift.y;
@@ -954,19 +958,24 @@
     if (smin > smax)
         return false;
     bool collides = false;
+    bool nooverlap = true;
 
     for (int i = smin; i <= smax; ++i)
     {
-        float t;
         float here = _edges[i] * rtl;
-        float y = (float)(_miny - 1 + (i + .5f) * _sliceWidth);  // vertical center of slice
-        if (    (x > here - _mingap - currSpace) )
+        if (here > (float)9e37)
+            continue;
+        if (!_hit || x > here - _mingap - currSpace)
         {
+            float y = (float)(_miny - 1 + (i + .5f) * _sliceWidth);  // vertical center of slice
             // 2 * currSpace to account for the space that is already separating them and the space we want to add
             float m = get_edge(seg, slot, currShift, y, _sliceWidth, 0., rtl > 0) * rtl + 2 * currSpace;
-            t = here - m;
+            if (m < (float)-8e37)       // only true if the glyph has a gap in it
+                continue;
+            nooverlap = false;
+            float t = here - m;
             // _mingap is positive to shrink
-            if (t < _mingap)
+            if (t < _mingap || (!_hit && !collides))
             {
                 _mingap = t;
                 collides = true;
@@ -980,8 +989,14 @@
             }
 #endif
         }
+        else
+            nooverlap = false;
     }
-    return collides;   // note that true is not a necessarily reliable value
+    if (nooverlap)
+        _mingap = max(_mingap, _xbound + currSpace + _margin - x);
+    if (collides && !nooverlap)
+        _hit = true;
+    return collides | nooverlap;   // note that true is not a necessarily reliable value
     
 }   // end of KernCollider::mergeSlot
 

Modified: trunk/Build/source/libs/graphite2/graphite2-src/src/Decompressor.cpp
===================================================================
--- trunk/Build/source/libs/graphite2/graphite2-src/src/Decompressor.cpp	2018-03-05 08:50:30 UTC (rev 46827)
+++ trunk/Build/source/libs/graphite2/graphite2-src/src/Decompressor.cpp	2018-03-05 09:10:55 UTC (rev 46828)
@@ -43,7 +43,8 @@
     return l;
 }
 
-bool read_sequence(u8 const * &src, u8 const * const end, u8 const * &literal, u32 & literal_len, u32 & match_len, u32 & match_dist)
+bool read_sequence(u8 const * &src, u8 const * const end, u8 const * &literal,
+                    u32 & literal_len, u32 & match_len, u32 & match_dist)
 {
     u8 const token = *src++;
     
@@ -50,15 +51,17 @@
     literal_len = read_literal(src, end, token >> 4);
     literal = src;
     src += literal_len;
-    
-    if (src > end - 2 || src < literal)
+
+    // Normal exit for end of stream, wrap arround check and parital match check.
+    if (src > end - sizeof(u16) || src < literal)
         return false;
     
     match_dist  = *src++;
     match_dist |= *src++ << 8;
-    match_len = read_literal(src, end, token & 0xf);
-    
-    return src <= end-5;
+    match_len = read_literal(src, end, token & 0xf) + MINMATCH;
+
+    // Malformed stream check.
+    return src <= end-MINCODA;
 }
 
 }
@@ -65,7 +68,7 @@
 
 int lz4::decompress(void const *in, size_t in_size, void *out, size_t out_size)
 {
-    if (out_size <= in_size || in_size < sizeof(unsigned long)+1)
+    if (out_size <= in_size || in_size < MINSRCSIZE)
         return -1;
     
     u8 const *       src     = static_cast<u8 const *>(in),
@@ -74,20 +77,28 @@
 
     u8 *       dst     = static_cast<u8*>(out),
        * const dst_end = dst + out_size;
-    
+
+    // Check the in and out size hasn't wrapped around.
+    if (src >= src_end || dst >= dst_end)
+        return -1;
+
     u32 literal_len = 0,
         match_len = 0,
         match_dist = 0;
-    
-    while (read_sequence(src, src_end, literal, literal_len, match_len, match_dist))
+
+    while (read_sequence(src, src_end, literal, literal_len, match_len,
+                         match_dist))
     {
         if (literal_len != 0)
         {
-            // Copy in literal. At this point the last full sequence must be at
-            // least MINMATCH + 5 from the end of the output buffer.
-            if (align(literal_len) > unsigned(dst_end - dst - (MINMATCH+5)) || dst_end - dst < MINMATCH + 5)
+            // Copy in literal. At this point the a minimal literal + minminal
+            // match plus the coda (1 + 2 + 5) must be 8 bytes or more allowing
+            // us to remain within the src buffer for an overrun_copy on
+            // machines upto 64 bits.
+            if (align(literal_len) > out_size)
                 return -1;
             dst = overrun_copy(dst, literal, literal_len);
+            out_size -= literal_len;
         }
         
         // Copy, possibly repeating, match from earlier in the
@@ -94,19 +105,19 @@
         //  decoded output.
         u8 const * const pcpy = dst - match_dist;
         if (pcpy < static_cast<u8*>(out)
-                  || pcpy >= dst
-                  || match_len > unsigned(dst_end - dst - (MINMATCH+5))
-                  || dst_end - dst < MINMATCH + 5)
+              || match_len > unsigned(out_size - LASTLITERALS)
+              // Wrap around checks:
+              || out_size < LASTLITERALS || pcpy >= dst)
             return -1;
-        if (dst > pcpy+sizeof(unsigned long) 
-            && dst + align(match_len + MINMATCH) <= dst_end)
-            dst = overrun_copy(dst, pcpy, match_len + MINMATCH);
-        else 
-            dst = safe_copy(dst, pcpy, match_len + MINMATCH);
+        if (dst > pcpy+sizeof(unsigned long)
+            && align(match_len) <= out_size)
+            dst = overrun_copy(dst, pcpy, match_len);
+        else
+            dst = safe_copy(dst, pcpy, match_len);
+        out_size -= match_len;
     }
-    
-    if (literal_len > src_end - literal
-              || literal_len > dst_end - dst)
+
+    if (literal > src_end - literal_len || literal_len > out_size)
         return -1;
     dst = fast_copy(dst, literal, literal_len);
     

Modified: trunk/Build/source/libs/graphite2/graphite2-src/src/FeatureMap.cpp
===================================================================
--- trunk/Build/source/libs/graphite2/graphite2-src/src/FeatureMap.cpp	2018-03-05 08:50:30 UTC (rev 46827)
+++ trunk/Build/source/libs/graphite2/graphite2-src/src/FeatureMap.cpp	2018-03-05 09:10:55 UTC (rev 46828)
@@ -73,7 +73,7 @@
     unsigned short & bits_offset, uint32 max_val,
     uint32 name, uint16 uiName, uint16 flags,
     FeatureSetting *settings, uint16 num_set) throw()
-: m_pFace(&face),
+: m_face(face),
   m_nameValues(settings),
   m_mask(mask_over_val(max_val)),
   m_max(max_val),
@@ -120,7 +120,7 @@
         return false;
     }
 
-    m_feats = new FeatureRef [m_numFeats];
+    m_feats = grzeroalloc<FeatureRef>(m_numFeats);
     uint16 * const  defVals = gralloc<uint16>(m_numFeats);
     if (!defVals || !m_feats) return false;
     unsigned short bits = 0;     //to cause overflow on first Feature
@@ -176,9 +176,9 @@
     for (int i = 0; i < m_numFeats; ++i)
     {
         m_feats[i].applyValToFeature(defVals[i], m_defaultFeatures);
-        m_pNamedFeats[i] = m_feats+i;
+        m_pNamedFeats[i] = m_feats[i];
     }
-    
+
     free(defVals);
 
     qsort(m_pNamedFeats, m_numFeats, sizeof(NameAndFeatureRef), &cmpNameAndFeatures);
@@ -267,13 +267,13 @@
 }
 
 bool FeatureRef::applyValToFeature(uint32 val, Features & pDest) const
-{ 
-    if (val>maxVal() || !m_pFace)
+{
+    if (val>maxVal())
       return false;
     if (pDest.m_pMap==NULL)
-      pDest.m_pMap = &m_pFace->theSill().theFeatureMap();
+      pDest.m_pMap = &m_face.theSill().theFeatureMap();
     else
-      if (pDest.m_pMap!=&m_pFace->theSill().theFeatureMap())
+      if (pDest.m_pMap!=&m_face.theSill().theFeatureMap())
         return false;       //incompatible
     if (m_index >= pDest.size())
         pDest.resize(m_index+1);
@@ -283,11 +283,9 @@
 }
 
 uint32 FeatureRef::getFeatureVal(const Features& feats) const
-{ 
-  if (m_index < feats.size() && &m_pFace->theSill().theFeatureMap()==feats.m_pMap) 
-    return (feats[m_index] & m_mask) >> m_bits; 
+{
+  if (m_index < feats.size() && &m_face.theSill().theFeatureMap()==feats.m_pMap)
+    return (feats[m_index] & m_mask) >> m_bits;
   else
     return 0;
 }
-
-

Modified: trunk/Build/source/libs/graphite2/graphite2-src/src/FileFace.cpp
===================================================================
--- trunk/Build/source/libs/graphite2/graphite2-src/src/FileFace.cpp	2018-03-05 08:50:30 UTC (rev 46827)
+++ trunk/Build/source/libs/graphite2/graphite2-src/src/FileFace.cpp	2018-03-05 09:10:55 UTC (rev 46828)
@@ -92,7 +92,7 @@
         return 0;
 
     tbl = malloc(tbl_len);
-    if (fread(tbl, 1, tbl_len, file_face._file) != tbl_len)
+    if (!tbl || fread(tbl, 1, tbl_len, file_face._file) != tbl_len)
     {
         free(tbl);
         return 0;

Modified: trunk/Build/source/libs/graphite2/graphite2-src/src/Pass.cpp
===================================================================
--- trunk/Build/source/libs/graphite2/graphite2-src/src/Pass.cpp	2018-03-05 08:50:30 UTC (rev 46827)
+++ trunk/Build/source/libs/graphite2/graphite2-src/src/Pass.cpp	2018-03-05 09:10:55 UTC (rev 46828)
@@ -171,7 +171,9 @@
     const uint16 * const o_actions = reinterpret_cast<const uint16 *>(p);
     be::skip<uint16>(p, m_numRules + 1);
     const byte * const states = p;
-    if (e.test(2u*m_numTransition*m_numColumns >= (unsigned)(pass_end - p), E_BADPASSLENGTH)) return face.error(e);
+    if (e.test(2u*m_numTransition*m_numColumns >= (unsigned)(pass_end - p), E_BADPASSLENGTH)
+            || e.test(p >= pass_end, E_BADPASSLENGTH))
+        return face.error(e);
     be::skip<int16>(p, m_numTransition*m_numColumns);
     be::skip<uint8>(p);
     if (e.test(p != pcCode, E_BADPASSCCODEPTR)) return face.error(e);
@@ -270,10 +272,11 @@
             return face.error(e);
     }
 
-    byte * moved_progs = static_cast<byte *>(realloc(m_progs, prog_pool_free - m_progs));
+    byte * const moved_progs = prog_pool_free > m_progs ? static_cast<byte *>(realloc(m_progs, prog_pool_free - m_progs)) : 0;
     if (e.test(!moved_progs, E_OUTOFMEM))
     {
-        if (prog_pool_free - m_progs == 0) m_progs = 0;
+        free(m_progs);
+        m_progs = 0;
         return face.error(e);
     }
 
@@ -714,9 +717,9 @@
     {
         while (++delta <= 0 && slot_out)
         {
+            slot_out = slot_out->prev();
             if (smap.highpassed() && smap.highwater() == slot_out)
                 smap.highpassed(false);
-            slot_out = slot_out->prev();
         }
     }
     else if (delta > 0)
@@ -723,9 +726,9 @@
     {
         while (--delta >= 0 && slot_out)
         {
-            slot_out = slot_out->next();
             if (slot_out == smap.highwater() && slot_out)
                 smap.highpassed(true);
+            slot_out = slot_out->next();
         }
     }
 }
@@ -968,8 +971,8 @@
         if (nbor != slotFix         						// don't process if this is the slot of interest
                       && !(cNbor->ignore())    				// don't process if ignoring
                       && (nbor == base || sameCluster       // process if in the same cluster as slotFix
-                            || !inKernCluster(seg, nbor)    // or this cluster is not to be kerned
-                            || (rtl ^ ignoreForKern))       // or it comes before(ltr) or after(rtl)
+                            || !inKernCluster(seg, nbor))   // or this cluster is not to be kerned
+//                            || (rtl ^ ignoreForKern))       // or it comes before(ltr) or after(rtl)
                       && (!isRev    // if processing forwards then good to merge otherwise only:
                             || !(cNbor->flags() & SlotCollision::COLL_FIX)     // merge in immovable stuff
                             || ((cNbor->flags() & SlotCollision::COLL_KERN) && !sameCluster)     // ignore other kernable clusters
@@ -1037,6 +1040,8 @@
         base = base->attachedTo();
     SlotCollision *cFix = seg->collisionInfo(base);
     const GlyphCache &gc = seg->getFace()->glyphs();
+    const Rect &bbb = seg->theGlyphBBoxTemporary(slotFix->gid());
+    const float by = slotFix->origin().y + cFix->shift().y;
 
     if (base != slotFix)
     {
@@ -1047,6 +1052,8 @@
     bool isInit = false;
     KernCollider coll(dbgout);
 
+    ymax = max(by + bbb.tr.y, ymax);
+    ymin = min(by + bbb.bl.y, ymin);
     for (nbor = slotFix->next(); nbor; nbor = nbor->next())
     {
         if (nbor->isChildOf(base))
@@ -1066,9 +1073,6 @@
         else
         {
             space_count = 0; 
-            float y = nbor->origin().y + cNbor->shift().y;
-            ymax = max(y + bb.tr.y, ymax);
-            ymin = min(y + bb.bl.y, ymin);
             if (nbor != slotFix && !cNbor->ignore())
             {
                 seenEnd = true;

Modified: trunk/Build/source/libs/graphite2/graphite2-src/src/SegCacheEntry.cpp
===================================================================
--- trunk/Build/source/libs/graphite2/graphite2-src/src/SegCacheEntry.cpp	2018-03-05 08:50:30 UTC (rev 46827)
+++ trunk/Build/source/libs/graphite2/graphite2-src/src/SegCacheEntry.cpp	2018-03-05 09:10:55 UTC (rev 46828)
@@ -42,7 +42,7 @@
     m_accessCount(0), m_lastAccess(cacheTime)
 {
     if (m_unicode)
-        for (uint16 i = 0; i < length; i++)
+        for (size_t i = 0; i < length; i++)
             m_unicode[i] = cmapGlyphs[i];
 
     const size_t    glyphCount = seg->slotCount(),

Modified: trunk/Build/source/libs/graphite2/graphite2-src/src/Segment.cpp
===================================================================
--- trunk/Build/source/libs/graphite2/graphite2-src/src/Segment.cpp	2018-03-05 08:50:30 UTC (rev 46827)
+++ trunk/Build/source/libs/graphite2/graphite2-src/src/Segment.cpp	2018-03-05 09:10:55 UTC (rev 46828)
@@ -59,7 +59,9 @@
   m_dir(textDir),
   m_flags(((m_silf->flags() & 0x20) != 0) << 1)
 {
-    freeSlot(newSlot());
+    Slot *s = newSlot();
+    if (s)
+        freeSlot(s);
     m_bufSize = log_binary(numchars)+1;
 }
 

Modified: trunk/Build/source/libs/graphite2/graphite2-src/src/Silf.cpp
===================================================================
--- trunk/Build/source/libs/graphite2/graphite2-src/src/Silf.cpp	2018-03-05 08:50:30 UTC (rev 46827)
+++ trunk/Build/source/libs/graphite2/graphite2-src/src/Silf.cpp	2018-03-05 09:10:55 UTC (rev 46828)
@@ -276,6 +276,7 @@
         return ERROROFFSET;
 
     // Check the linear offsets are sane, these must be monotonically increasing.
+    assert(m_nClass >= m_nLinear);
     for (const uint32 *o = m_classOffsets, * const o_end = o + m_nLinear; o != o_end; ++o)
         if (e.test(o[0] > o[1], E_BADCLASSOFFSET))
             return ERROROFFSET;

Modified: trunk/Build/source/libs/graphite2/graphite2-src/src/TtfUtil.cpp
===================================================================
--- trunk/Build/source/libs/graphite2/graphite2-src/src/TtfUtil.cpp	2018-03-05 08:50:30 UTC (rev 46827)
+++ trunk/Build/source/libs/graphite2/graphite2-src/src/TtfUtil.cpp	2018-03-05 09:10:55 UTC (rev 46828)
@@ -341,6 +341,11 @@
         return be::swap(pName->format) == 0;
     }
 
+    case Tag::glyf:
+    {
+        return (lTableSize >= sizeof(Sfnt::Glyph));
+    }
+
     default:
         break;
     }
@@ -464,7 +469,7 @@
 {
     const Sfnt::FontHeader * pTable = 
             reinterpret_cast<const Sfnt::FontHeader *>(pHead);
-    
+   ; 
     *pnDateBC = be::swap(pTable->modified[0]);
     *pnDateAD = be::swap(pTable->modified[1]);
 }
@@ -1247,7 +1252,7 @@
 void * GlyfLookup(const void * pGlyf, size_t nGlyfOffset, size_t nTableLen)
 {
     const uint8 * pByte = reinterpret_cast<const uint8 *>(pGlyf);
-        if (nGlyfOffset + pByte < pByte || nGlyfOffset + sizeof(Sfnt::Glyph) >= nTableLen)
+        if (nGlyfOffset + pByte < pByte || nGlyfOffset >= nTableLen - sizeof(Sfnt::Glyph))
             return NULL;
     return const_cast<uint8 *>(pByte + nGlyfOffset);
 }

Modified: trunk/Build/source/libs/graphite2/graphite2-src/src/gr_face.cpp
===================================================================
--- trunk/Build/source/libs/graphite2/graphite2-src/src/gr_face.cpp	2018-03-05 08:50:30 UTC (rev 46827)
+++ trunk/Build/source/libs/graphite2/graphite2-src/src/gr_face.cpp	2018-03-05 09:10:55 UTC (rev 46828)
@@ -195,7 +195,7 @@
 
 void gr_face_destroy(gr_face *face)
 {
-    delete face;
+    delete static_cast<Face*>(face);
 }
 
 

Modified: trunk/Build/source/libs/graphite2/graphite2-src/src/gr_features.cpp
===================================================================
--- trunk/Build/source/libs/graphite2/graphite2-src/src/gr_features.cpp	2018-03-05 08:50:30 UTC (rev 46827)
+++ trunk/Build/source/libs/graphite2/graphite2-src/src/gr_features.cpp	2018-03-05 09:10:55 UTC (rev 46828)
@@ -80,7 +80,7 @@
 
 void* gr_fref_label(const gr_feature_ref* pfeatureref, gr_uint16 *langId, gr_encform utf, gr_uint32 *length)
 {
-    if(!pfeatureref || !pfeatureref->getFace())
+    if(!pfeatureref)
     {
         langId = 0;
         length = 0;
@@ -87,7 +87,7 @@
         return NULL;
     }
     uint16 label = pfeatureref->getNameId();
-    NameTable * names = pfeatureref->getFace()->nameTable();
+    NameTable * names = pfeatureref->getFace().nameTable();
     if (!names)
     {
         langId = 0;
@@ -101,7 +101,7 @@
 void* gr_fref_value_label(const gr_feature_ref*pfeatureref, gr_uint16 setting,
     gr_uint16 *langId, gr_encform utf, gr_uint32 *length)
 {
-    if(!pfeatureref || (setting >= pfeatureref->getNumSettings()) || !pfeatureref->getFace())
+    if(!pfeatureref || (setting >= pfeatureref->getNumSettings()))
     {
         langId = 0;
         length = 0;
@@ -108,7 +108,7 @@
         return NULL;
     }
     uint16 label = pfeatureref->getSettingName(setting);
-    NameTable * names = pfeatureref->getFace()->nameTable();
+    NameTable * names = pfeatureref->getFace().nameTable();
     if (!names)
     {
         langId = 0;
@@ -131,7 +131,7 @@
   
 void gr_featureval_destroy(gr_feature_val *p)
 {
-    delete p;
+    delete static_cast<Features*>(p);
 }
 
 

Modified: trunk/Build/source/libs/graphite2/graphite2-src/src/gr_font.cpp
===================================================================
--- trunk/Build/source/libs/graphite2/graphite2-src/src/gr_font.cpp	2018-03-05 08:50:30 UTC (rev 46827)
+++ trunk/Build/source/libs/graphite2/graphite2-src/src/gr_font.cpp	2018-03-05 09:10:55 UTC (rev 46828)
@@ -47,10 +47,16 @@
 
 gr_font* gr_make_font_with_ops(float ppm/*pixels per em*/, const void* appFontHandle/*non-NULL*/, const gr_font_ops * font_ops, const gr_face * face/*needed for scaling*/)
 {                 //the appFontHandle must stay alive all the time when the gr_font is alive. When finished with the gr_font, call destroy_gr_font    
-    if (face == 0)  return 0;
+    if (face == 0 || ppm <= 0)  return 0;
 
     Font * const res = new Font(ppm, *face, appFontHandle, font_ops);
-    return static_cast<gr_font*>(res);
+    if (*res)
+        return static_cast<gr_font*>(res);
+    else
+    {
+        delete res;
+        return 0;
+    }
 }
 
 gr_font* gr_make_font_with_advance_fn(float ppm/*pixels per em*/, const void* appFontHandle/*non-NULL*/, gr_advance_fn getAdvance, const gr_face * face/*needed for scaling*/)
@@ -61,7 +67,7 @@
 
 void gr_font_destroy(gr_font *font)
 {
-    delete font;
+    delete static_cast<Font*>(font);
 }
 
 

Modified: trunk/Build/source/libs/graphite2/graphite2-src/src/gr_logging.cpp
===================================================================
--- trunk/Build/source/libs/graphite2/graphite2-src/src/gr_logging.cpp	2018-03-05 08:50:30 UTC (rev 46827)
+++ trunk/Build/source/libs/graphite2/graphite2-src/src/gr_logging.cpp	2018-03-05 09:10:55 UTC (rev 46828)
@@ -41,7 +41,7 @@
 using namespace graphite2;
 
 #if !defined GRAPHITE2_NTRACING
-json *global_log = NULL;
+json *global_log = 0;
 #endif
 
 extern "C" {
@@ -120,6 +120,7 @@
     {
         FILE * log = global_log->stream();
         delete global_log;
+        global_log = 0;
         fclose(log);
     }
 #endif
@@ -214,7 +215,7 @@
     j << "user" << json::flat << json::array;
     for (int n = 0; n!= seg.numAttrs(); ++n)
         j   << s.userAttrs()[n];
-        j   << json::close;
+    j       << json::close;
     if (s.firstChild())
     {
         j   << "children" << json::flat << json::array;

Modified: trunk/Build/source/libs/graphite2/graphite2-src/src/gr_segment.cpp
===================================================================
--- trunk/Build/source/libs/graphite2/graphite2-src/src/gr_segment.cpp	2018-03-05 08:50:30 UTC (rev 46827)
+++ trunk/Build/source/libs/graphite2/graphite2-src/src/gr_segment.cpp	2018-03-05 09:10:55 UTC (rev 46828)
@@ -103,7 +103,7 @@
     if (pFeats == 0)
         pFeats = tmp_feats = static_cast<const gr_feature_val*>(face->theSill().cloneFeatures(0));
     gr_segment * seg = makeAndInitialize(font, face, script, pFeats, enc, pStart, nChars, dir);
-    delete tmp_feats;
+    delete static_cast<const FeatureVal*>(tmp_feats);
 
     return seg;
 }
@@ -111,7 +111,7 @@
 
 void gr_seg_destroy(gr_segment* p)
 {
-    delete p;
+    delete static_cast<Segment*>(p);
 }
 
 

Modified: trunk/Build/source/libs/graphite2/graphite2-src/src/inc/Code.h
===================================================================
--- trunk/Build/source/libs/graphite2/graphite2-src/src/inc/Code.h	2018-03-05 08:50:30 UTC (rev 46827)
+++ trunk/Build/source/libs/graphite2/graphite2-src/src/inc/Code.h	2018-03-05 09:10:55 UTC (rev 46828)
@@ -162,7 +162,7 @@
 {
     if (_code && !_own)
     {
-        _code += dist / sizeof(instr);
+        _code += dist / signed(sizeof(instr));
         _data += dist;
     }
 }

Modified: trunk/Build/source/libs/graphite2/graphite2-src/src/inc/Collider.h
===================================================================
--- trunk/Build/source/libs/graphite2/graphite2-src/src/inc/Collider.h	2018-03-05 08:50:30 UTC (rev 46827)
+++ trunk/Build/source/libs/graphite2/graphite2-src/src/inc/Collider.h	2018-03-05 09:10:55 UTC (rev 46828)
@@ -210,6 +210,7 @@
     float _sliceWidth;      // width of each slice
     float _mingap;
     float _xbound;        // max or min edge
+    bool  _hit;
 
 #if !defined GRAPHITE2_NTRACING    
     // Debugging
@@ -233,7 +234,8 @@
   _maxy(1e38f),
   _sliceWidth(0.0f),
   _mingap(0.0f),
-  _xbound(0.0)
+  _xbound(0.0),
+  _hit(false)
 {
 #if !defined GRAPHITE2_NTRACING
     _seg = 0;

Modified: trunk/Build/source/libs/graphite2/graphite2-src/src/inc/Compression.h
===================================================================
--- trunk/Build/source/libs/graphite2/graphite2-src/src/inc/Compression.h	2018-03-05 08:50:30 UTC (rev 46827)
+++ trunk/Build/source/libs/graphite2/graphite2-src/src/inc/Compression.h	2018-03-05 09:10:55 UTC (rev 46828)
@@ -47,7 +47,10 @@
 typedef uint64_t u64;
 #endif
 
-ptrdiff_t const     MINMATCH  = 4;
+ptrdiff_t const     MINMATCH = 4,
+                    LASTLITERALS = 5,
+                    MINCODA  = LASTLITERALS+1,
+                    MINSRCSIZE = 13;
 
 template<int S>
 inline 

Modified: trunk/Build/source/libs/graphite2/graphite2-src/src/inc/FeatureMap.h
===================================================================
--- trunk/Build/source/libs/graphite2/graphite2-src/src/inc/FeatureMap.h	2018-03-05 08:50:30 UTC (rev 46827)
+++ trunk/Build/source/libs/graphite2/graphite2-src/src/inc/FeatureMap.h	2018-03-05 09:10:55 UTC (rev 46828)
@@ -56,7 +56,6 @@
     static const uint8  SIZEOF_CHUNK = sizeof(chunk_t)*8;
 
 public:
-    FeatureRef();
     FeatureRef(const Face & face, unsigned short & bits_offset, uint32 max_val,
                uint32 name, uint16 uiName, uint16 flags,
                FeatureSetting *settings, uint16 num_set) throw();
@@ -76,7 +75,7 @@
     uint16 getSettingName(uint16 index) const { return m_nameValues[index].label(); }
     int16  getSettingValue(uint16 index) const { return m_nameValues[index].value(); }
     uint32 maxVal() const { return m_max; }
-    const Face* getFace() const { return m_pFace;}
+    const Face & getFace() const { return m_face;}
     const FeatureMap* getFeatureMap() const;// { return m_pFace;}
 
     CLASS_NEW_DELETE;
@@ -83,7 +82,7 @@
 private:
     FeatureRef(const FeatureRef & rhs);
 
-    const Face     * m_pFace;   //not NULL
+    const Face     & m_face;
     FeatureSetting * m_nameValues; // array of name table ids for feature values
     chunk_t m_mask,             // bit mask to get the value from the vector
             m_max;              // max value the value can take
@@ -99,27 +98,18 @@
 };
 
 
-inline
-FeatureRef::FeatureRef()
-: m_pFace(0), m_nameValues(0),
-  m_mask(0), m_max(0), m_id(0),
-  m_nameid(0), m_flags(0), m_numSet(0),
-  m_bits(0), m_index(0)
-{
-}
 
-
 class NameAndFeatureRef
 {
   public:
     NameAndFeatureRef(uint32 name = 0) : m_name(name) , m_pFRef(NULL){}
-    NameAndFeatureRef(const FeatureRef* p/*not NULL*/) : m_name(p->getId()), m_pFRef(p) {}
+    NameAndFeatureRef(FeatureRef const & p) : m_name(p.getId()), m_pFRef(&p) {}
 
     bool operator<(const NameAndFeatureRef& rhs) const //orders by m_name
         {   return m_name<rhs.m_name; }
 
     CLASS_NEW_DELETE
- 
+
     uint32 m_name;
     const FeatureRef* m_pFRef;
 };
@@ -128,7 +118,7 @@
 {
 public:
     FeatureMap() : m_numFeats(0), m_feats(NULL), m_pNamedFeats(NULL) {}
-    ~FeatureMap() { delete [] m_feats; delete[] m_pNamedFeats; }
+    ~FeatureMap() { free(m_feats); delete[] m_pNamedFeats; }
 
     bool readFeats(const Face & face);
     const FeatureRef *findFeatureRef(uint32 name) const;

Modified: trunk/Build/source/libs/graphite2/graphite2-src/src/inc/Font.h
===================================================================
--- trunk/Build/source/libs/graphite2/graphite2-src/src/inc/Font.h	2018-03-05 08:50:30 UTC (rev 46827)
+++ trunk/Build/source/libs/graphite2/graphite2-src/src/inc/Font.h	2018-03-05 09:10:55 UTC (rev 46828)
@@ -44,6 +44,7 @@
     float scale() const;
     bool isHinted() const;
     const Face & face() const;
+    operator bool () const throw()  { return m_advances; }
 
     CLASS_NEW_DELETE;
 private:

Modified: trunk/Build/source/libs/graphite2/graphite2-src/src/inc/List.h
===================================================================
--- trunk/Build/source/libs/graphite2/graphite2-src/src/inc/List.h	2018-03-05 08:50:30 UTC (rev 46827)
+++ trunk/Build/source/libs/graphite2/graphite2-src/src/inc/List.h	2018-03-05 09:10:55 UTC (rev 46828)
@@ -34,6 +34,7 @@
 #include <cstdlib>
 #include <new>
 
+#include "Main.h"
 
 namespace graphite2 {
 
@@ -104,7 +105,9 @@
     if (n > capacity()) 
     {
         const ptrdiff_t sz = size();
-        m_first = static_cast<T*>(realloc(m_first, n*sizeof(T)));
+        size_t requested;
+        if (checked_mul(n,sizeof(T), requested))  std::abort();
+        m_first = static_cast<T*>(realloc(m_first, requested));
         if (!m_first)   std::abort();
         m_last  = m_first + sz;
         m_end   = m_first + n;

Modified: trunk/Build/source/libs/graphite2/graphite2-src/src/inc/Machine.h
===================================================================
--- trunk/Build/source/libs/graphite2/graphite2-src/src/inc/Machine.h	2018-03-05 08:50:30 UTC (rev 46827)
+++ trunk/Build/source/libs/graphite2/graphite2-src/src/inc/Machine.h	2018-03-05 09:10:55 UTC (rev 46828)
@@ -15,8 +15,8 @@
 
     You should also have received a copy of the GNU Lesser General Public
     License along with this library in the file named "LICENSE".
-    If not, write to the Free Software Foundation, 51 Franklin Street, 
-    Suite 500, Boston, MA 02110-1335, USA or visit their web page on the 
+    If not, write to the Free Software Foundation, 51 Franklin Street,
+    Suite 500, Boston, MA 02110-1335, USA or visit their web page on the
     internet at http://www.fsf.org/licenses/lgpl.html.
 
 Alternatively, the contents of this file may be used under the terms of the
@@ -27,11 +27,12 @@
 // This general interpreter interface.
 // Author: Tim Eves
 
-// Build one of direct_machine.cpp or call_machine.cpp to implement this 
+// Build one of direct_machine.cpp or call_machine.cpp to implement this
 // interface.
 
 #pragma once
 #include <cstring>
+#include <limits>
 #include <graphite2/Types.h>
 #include "inc/Main.h"
 
@@ -56,6 +57,13 @@
 #define     REGPARM(n)
 #endif
 
+#if defined(__MINGW32__)
+// MinGW's <limits> at some point includes winnt.h which #define's a
+// DELETE macro, which conflicts with enum opcode below, so we undefine
+// it here.
+#undef DELETE
+#endif
+
 namespace graphite2 {
 
 // Forward declarations
@@ -64,7 +72,7 @@
 class SlotMap;
 
 
-namespace vm 
+namespace vm
 {
 
 
@@ -112,12 +120,12 @@
     PUT_GLYPH,                      PUSH_GLYPH_ATTR,    PUSH_ATT_TO_GLYPH_ATTR,
     BITOR,                          BITAND,             BITNOT,
     BITSET,                         SET_FEAT,
-    MAX_OPCODE,                     
+    MAX_OPCODE,
     // private opcodes for internal use only, comes after all other on disk opcodes
     TEMP_COPY = MAX_OPCODE
 };
 
-struct opcode_t 
+struct opcode_t
 {
     instr           impl[2];
     uint8           param_sz;
@@ -186,6 +194,8 @@
 
 inline void Machine::check_final_stack(const stack_t * const sp)
 {
+    if (_status != finished) return;
+
     stack_t const * const base  = _stack + STACK_GUARD,
                   * const limit = base + STACK_MAX;
     if      (sp <  base)    _status = stack_underflow;       // This should be impossible now.
@@ -195,6 +205,3 @@
 
 } // namespace vm
 } // namespace graphite2
-
-
-

Modified: trunk/Build/source/libs/graphite2/graphite2-src/src/inc/Main.h
===================================================================
--- trunk/Build/source/libs/graphite2/graphite2-src/src/inc/Main.h	2018-03-05 08:50:30 UTC (rev 46827)
+++ trunk/Build/source/libs/graphite2/graphite2-src/src/inc/Main.h	2018-03-05 09:10:55 UTC (rev 46828)
@@ -15,8 +15,8 @@
 
     You should also have received a copy of the GNU Lesser General Public
     License along with this library in the file named "LICENSE".
-    If not, write to the Free Software Foundation, 51 Franklin Street, 
-    Suite 500, Boston, MA 02110-1335, USA or visit their web page on the 
+    If not, write to the Free Software Foundation, 51 Franklin Street,
+    Suite 500, Boston, MA 02110-1335, USA or visit their web page on the
     internet at http://www.fsf.org/licenses/lgpl.html.
 
 Alternatively, the contents of this file may be used under the terms of the
@@ -77,15 +77,61 @@
 struct telemetry  {};
 #endif
 
+// Checked multiplaction to catch overflow or underflow when allocating memory
+#if defined(__has_builtin)
+  #if __has_builtin(__builtin_mul_overflow)
+    #define HAVE_BUILTIN_OVERFLOW
+  #endif
+#elif defined(__GNUC__) && (__GNUC__ >= 5) && !defined(__INTEL_COMPILER)
+  #define HAVE_BUILTIN_OVERFLOW
+#endif
+#if defined(__has_include)
+  #if __has_include(<intsafe.h>)
+    #define HAVE_INTSAFE_H
+  #endif
+#elif defined(_WIN32)
+  #define HAVE_INTSAFE_H
+#endif
+
+// Need to import intsafe into the top level namespace
+#if defined(HAVE_INTSAFE_H)
+} // namespace graphite2
+
+#include <intsafe.h>
+
+namespace graphite2 {
+#endif
+
+#if defined(HAVE_BUILTIN_OVERFLOW)
+inline
+bool checked_mul(const size_t a, const size_t b, size_t & t) {
+    return __builtin_mul_overflow(a, b, &t);
+}
+#elif defined(HAVE_INTSAFE_H)
+inline
+bool checked_mul(const size_t a, const size_t b, size_t & t) {
+    return SizeTMult(a, b, &t) == INTSAFE_E_ARITHMETIC_OVERFLOW;
+}
+#else
+inline
+bool checked_mul(const size_t a, const size_t b, size_t & t) {
+  t = a*b;
+  return (((a | b) & (~size_t(0) << (sizeof(size_t) << 2))) && (t / a != b));
+}
+#endif
+
 // typesafe wrapper around malloc for simple types
 // use free(pointer) to deallocate
 
 template <typename T> T * gralloc(size_t n)
 {
+    size_t total;
+    if (checked_mul(n, sizeof(T), total))
+      return 0;
 #ifdef GRAPHITE2_TELEMETRY
-    telemetry::count_bytes(sizeof(T) * n);
+    telemetry::count_bytes(total);
 #endif
-    return static_cast<T*>(malloc(sizeof(T) * n));
+    return static_cast<T*>(malloc(total));
 }
 
 template <typename T> T * grzeroalloc(size_t n)
@@ -128,7 +174,7 @@
 
 #if defined(__clang__) && __cplusplus >= 201103L
    /* clang's fallthrough annotations are only available starting in C++11. */
-    #define GR_FALLTHROUGH [[clang::fallthrough]]
+    #define GR_FALLTHROUGH [[fallthrough]]
 #elif defined(_MSC_VER)
    /*
     * MSVC's __fallthrough annotations are checked by /analyze (Code Analysis):
@@ -136,6 +182,8 @@
     */
     #include <sal.h>
     #define GR_FALLTHROUGH __fallthrough
+#elif __GNUC__ >= 7
+    #define GR_FALLTHROUGH __attribute__ ((fallthrough))
 #else
     #define GR_FALLTHROUGH /* fallthrough */
 #endif

Modified: trunk/Build/source/libs/graphite2/graphite2-src/src/inc/Segment.h
===================================================================
--- trunk/Build/source/libs/graphite2/graphite2-src/src/inc/Segment.h	2018-03-05 08:50:30 UTC (rev 46827)
+++ trunk/Build/source/libs/graphite2/graphite2-src/src/inc/Segment.h	2018-03-05 09:10:55 UTC (rev 46828)
@@ -205,7 +205,7 @@
 inline
 void Segment::finalise(const Font *font, bool reverse)
 {
-    if (!m_first) return;
+    if (!m_first || !m_last) return;
 
     m_advance = positionSlots(font, m_first, m_last, m_silf->dir(), true);
     //associateChars(0, m_numCharinfo);

Modified: trunk/Build/source/libs/graphite2/graphite2-src/src/inc/Sparse.h
===================================================================
--- trunk/Build/source/libs/graphite2/graphite2-src/src/inc/Sparse.h	2018-03-05 08:50:30 UTC (rev 46827)
+++ trunk/Build/source/libs/graphite2/graphite2-src/src/inc/Sparse.h	2018-03-05 09:10:55 UTC (rev 46828)
@@ -15,8 +15,8 @@
 
     You should also have received a copy of the GNU Lesser General Public
     License along with this library in the file named "LICENSE".
-    If not, write to the Free Software Foundation, 51 Franklin Street, 
-    Suite 500, Boston, MA 02110-1335, USA or visit their web page on the 
+    If not, write to the Free Software Foundation, 51 Franklin Street,
+    Suite 500, Boston, MA 02110-1335, USA or visit their web page on the
     internet at http://www.fsf.org/licenses/lgpl.html.
 
 Alternatively, the contents of this file may be used under the terms of the
@@ -73,7 +73,7 @@
     size_t size()     const throw();
 
     size_t _sizeof() const throw();
-    
+
     CLASS_NEW_DELETE;
 
 private:
@@ -122,10 +122,7 @@
                                                  + n_values);
 
     if (m_array.values == 0)
-    {
-        free(m_array.values); m_array.map=0;
         return;
-    }
 
     // coverity[forward_null : FALSE] Since m_array is union and m_array.values is not NULL
     chunk * ci = m_array.map;

Modified: trunk/Build/source/libs/graphite2/graphite2-src/src/inc/opcode_table.h
===================================================================
--- trunk/Build/source/libs/graphite2/graphite2-src/src/inc/opcode_table.h	2018-03-05 08:50:30 UTC (rev 46827)
+++ trunk/Build/source/libs/graphite2/graphite2-src/src/inc/opcode_table.h	2018-03-05 09:10:55 UTC (rev 46828)
@@ -73,7 +73,7 @@
     {{do2(gtr_eq)},                                 0, "GTR_EQ"},   // 0x18
 
     {{do_(next), NILOP},                            0, "NEXT"},
-    {{do_(next_n), NILOP},                          1, "NEXT_N"},                   // number <= smap.end - map
+    {{NILOP, NILOP},                                1, "NEXT_N"},                   // number <= smap.end - map
     {{do_(next), NILOP},                            0, "COPY_NEXT"},
     {{do_(put_glyph_8bit_obs), NILOP},              1, "PUT_GLYPH_8BIT_OBS"},       // output_class
     {{do_(put_subs_8bit_obs), NILOP},               3, "PUT_SUBS_8BIT_OBS"},        // slot input_class output_class

Modified: trunk/Build/source/libs/graphite2/graphite2-src/src/inc/opcodes.h
===================================================================
--- trunk/Build/source/libs/graphite2/graphite2-src/src/inc/opcodes.h	2018-03-05 08:50:30 UTC (rev 46827)
+++ trunk/Build/source/libs/graphite2/graphite2-src/src/inc/opcodes.h	2018-03-05 09:10:55 UTC (rev 46828)
@@ -26,7 +26,7 @@
 */
 #pragma once
 // This file will be pulled into and integrated into a machine implmentation
-// DO NOT build directly and under no circumstances every #include headers in 
+// DO NOT build directly and under no circumstances ever #include headers in
 // here or you will break the direct_machine.
 //
 // Implementers' notes
@@ -65,7 +65,7 @@
      
 
 // #define NOT_IMPLEMENTED     assert(false)
-#define NOT_IMPLEMENTED
+// #define NOT_IMPLEMENTED
 
 #define binop(op)           const uint32 a = pop(); *sp = uint32(*sp) op a
 #define sbinop(op)          const int32 a = pop(); *sp = int32(*sp) op a
@@ -130,8 +130,10 @@
 ENDOP
 
 STARTOP(div_)
-    if (*sp == 0) DIE;
-    sbinop(/);
+    const int32 b = pop();
+    const int32 a = int32(*sp);
+    if (b == 0 || (a == std::numeric_limits<int32>::min() && b == -1)) DIE;
+    *sp = int32(*sp) / b;
 ENDOP
 
 STARTOP(min_)
@@ -208,12 +210,12 @@
     ++map;
 ENDOP
 
-STARTOP(next_n)
-    use_params(1);
-    NOT_IMPLEMENTED;
+//STARTOP(next_n)
+//    use_params(1);
+//    NOT_IMPLEMENTED;
     //declare_params(1);
     //const size_t num = uint8(*param);
-ENDOP
+//ENDOP
 
 //STARTOP(copy_next)
 //     if (is) is = is->next();
@@ -337,6 +339,7 @@
     else
         seg.last(is->prev());
     
+
     if (is == smap.highwater())
             smap.highwater(is->next());
     if (is->prev())

Modified: trunk/Build/source/libs/graphite2/version.ac
===================================================================
--- trunk/Build/source/libs/graphite2/version.ac	2018-03-05 08:50:30 UTC (rev 46827)
+++ trunk/Build/source/libs/graphite2/version.ac	2018-03-05 09:10:55 UTC (rev 46828)
@@ -8,4 +8,4 @@
 dnl --------------------------------------------------------
 dnl
 dnl  m4-include this file to define the current graphite2 version
-m4_define([graphite2_version], [1.3.10])
+m4_define([graphite2_version], [1.3.11])



More information about the tex-live-commits mailing list