Bug 1448771 - Merge fix from upstream. r=ryanvm, a=RyanVM
authorJonathan Kew <jkew@mozilla.com>
Mon, 26 Mar 2018 20:35:48 +0100
changeset 460439 75cefda36f283a32b8b48f5ac7924f4d41b44463
parent 460438 2f2e601e1394cbe2965a65f0218708eec9d5b81d
child 460440 2bb8a74aa36cfb0430bfdab09adb7fcce0dab1c7
push id8942
push userryanvm@gmail.com
push dateThu, 29 Mar 2018 14:09:55 +0000
treeherdermozilla-beta@75cefda36f28 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersryanvm, RyanVM
bugs1448771
milestone60.0
Bug 1448771 - Merge fix from upstream. r=ryanvm, a=RyanVM
intl/hyphenation/hyphen/hyphen.c
--- a/intl/hyphenation/hyphen/hyphen.c
+++ b/intl/hyphenation/hyphen/hyphen.c
@@ -433,21 +433,35 @@ for (k = 0; k < 2; k++) {
     dict[k]->utf8 = (strcmp(dict[k]->cset, "UTF-8") == 0);
   } else {
     strncpy(dict[k]->cset, dict[0]->cset, sizeof(dict[k]->cset)-1);
     dict[k]->cset[sizeof(dict[k]->cset)-1] = '\0';
     dict[k]->utf8 = dict[0]->utf8;
   }
 
   if (k == 0 || nextlevel) {
-    while (fgets (buf, sizeof(buf), f) != NULL) {
+    while (fgets(buf, sizeof(buf), f) != NULL) {
+      
+      /* discard lines that don't fit in buffer */
+      if (!feof(f) && strchr(buf, '\n') == NULL) {
+        int c;
+        while ((c = fgetc(f)) != '\n' && c != EOF);
+        /* issue warning if not a comment */
+        if (buf[0] != '%') {
+          fprintf(stderr, "Warning: skipping too long pattern (more than %lu chars)\n", sizeof(buf));
+        }
+        continue;
+      }
+      
       if (strncmp(buf, "NEXTLEVEL", 9) == 0) {
-	nextlevel = 1;
-	break;
-      } else if (buf[0] != '%') hnj_hyphen_load_line(buf, dict[k], hashtab);
+        nextlevel = 1;
+        break;
+      } else if (buf[0] != '%') {
+        hnj_hyphen_load_line(buf, dict[k], hashtab);
+      }
     }
   } else if (k == 1) {
     /* default first level: hyphen and ASCII apostrophe */
     if (!dict[0]->utf8) hnj_hyphen_load_line("NOHYPHEN ',-\n", dict[k], hashtab);
     else hnj_hyphen_load_line("NOHYPHEN ',\xe2\x80\x93,\xe2\x80\x99,-\n", dict[k], hashtab);
     strncpy(buf, "1-1\n", MAX_CHARS-1); /* buf rewritten by hnj_hyphen_load here */
     buf[MAX_CHARS-1] = '\0';
     hnj_hyphen_load_line(buf, dict[k], hashtab); /* remove hyphen */