diff --git a/src/core/fonts.js b/src/core/fonts.js
index f21c05e85..a56797534 100644
--- a/src/core/fonts.js
+++ b/src/core/fonts.js
@@ -3717,6 +3717,11 @@ var Font = (function FontClosure() {
         if (ttContext.tooComplexToFollowFunctions) {
           return;
         }
+        if (ttContext.functionsDefined.length > maxFunctionDefs) {
+          warn('TT: more functions defined than expected');
+          ttContext.hintsValid = false;
+          return;
+        }
         for (var j = 0, jj = ttContext.functionsUsed.length; j < jj; j++) {
           if (j > maxFunctionDefs) {
             warn('TT: invalid function id: ' + j);